samples: net: http: Remove obsolete files from server sample
There was some left overs from earlier version of http_server sample application. Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
4f69bdaa0d
commit
c9d21ef831
4 changed files with 0 additions and 166 deletions
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "http_types.h"
|
||||
#include "http_server.h"
|
||||
#include "http_utils.h"
|
||||
#include "http_write_utils.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <net/http_parser.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#define HTTP_BUF_CTR HTTP_MAX_NUMBER_SERVER_CTX
|
||||
#define HTTP_BUF_SIZE 1024
|
||||
|
||||
/**
|
||||
* @brief parser_parse_request Parses an HTTP REQUEST
|
||||
* @param ctx HTTP server context
|
||||
* @param rx Input buffer
|
||||
* @return 0 on success
|
||||
* @return -EINVAL on error
|
||||
*/
|
||||
static
|
||||
int parser_parse_request(struct http_server_ctx *ctx, struct net_buf *rx);
|
||||
|
||||
static struct http_root_url *http_url_find(struct http_server_ctx *http_ctx);
|
||||
|
||||
static int http_url_cmp(const char *url, u16_t url_len,
|
||||
const char *root_url, u16_t root_url_len);
|
||||
|
||||
static void http_tx(struct http_server_ctx *http_ctx);
|
||||
|
||||
|
||||
/**
|
||||
* @brief server_collection This is a collection of server ctx structs
|
||||
*/
|
||||
static struct http_server_ctx server_ctx[CONFIG_HTTP_SERVER_CONNECTIONS];
|
||||
|
||||
/**
|
||||
* @brief http_url_ctx Just one URL context per application
|
||||
*/
|
||||
static struct http_url_ctx url_ctx;
|
||||
|
||||
int http_auth(struct http_server_ctx *ctx)
|
||||
{
|
||||
const char *auth_str = "Authorization: Basic "HTTP_AUTH_CREDENTIALS;
|
||||
|
||||
if (strstr(ctx->field_values[0].key, auth_str)) {
|
||||
return http_response_auth(ctx);
|
||||
}
|
||||
|
||||
return http_response_401(ctx);
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _HTTP_SERVER_H_
|
||||
#define _HTTP_SERVER_H_
|
||||
|
||||
#include <net/net_context.h>
|
||||
|
||||
/* Callback executed when a new connection is accepted */
|
||||
void http_accept_cb(struct net_context *net_ctx, struct sockaddr *addr,
|
||||
socklen_t addr_len, int status, void *data);
|
||||
|
||||
/**
|
||||
* @brief http_rx_tx Reads the HTTP request from the `rx` buffer
|
||||
* and writes an HTTP 1.1 200 OK response with client
|
||||
* header fields or an error message
|
||||
* @param ctx The network context
|
||||
* @param rx The received packet
|
||||
* @param status Connection status, see `net_context_recv_cb_t`
|
||||
* @param user_data User-provided data
|
||||
*/
|
||||
void http_rx_tx(struct net_context *ctx, struct net_pkt *rx, int status,
|
||||
void *user_data);
|
||||
|
||||
/**
|
||||
* @brief http_ctx_init Initializes the HTTP server contexts collection
|
||||
* @return 0, future versions may return error codes
|
||||
*/
|
||||
int http_ctx_init(void);
|
||||
|
||||
/**
|
||||
* @brief http_ctx_get Gets an HTTP server context struct
|
||||
* @return A valid HTTP server ctx on success
|
||||
* @return NULL on error
|
||||
*/
|
||||
struct http_server_ctx *http_ctx_get(void);
|
||||
|
||||
/**
|
||||
* @brief http_ctx_set Assigns the net_ctx pointer to the HTTP ctx
|
||||
* @param http_ctx HTTP server context struct
|
||||
* @param net_ctx Network context
|
||||
* @return 0 on success
|
||||
* @return -EINVAL on error
|
||||
*/
|
||||
int http_ctx_set(struct http_server_ctx *http_ctx, struct net_context *net_ctx);
|
||||
|
||||
int http_url_default_handler(int (*write_cb)(struct http_server_ctx *));
|
||||
|
||||
int http_url_add(const char *url, u8_t flags,
|
||||
int (*write_cb)(struct http_server_ctx *http_ctx));
|
||||
|
||||
int http_auth(struct http_server_ctx *ctx);
|
||||
|
||||
#endif
|
|
@ -1,25 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "http_write_utils.h"
|
||||
#include "http_types.h"
|
||||
#include "http_utils.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int http_response_401(struct http_server_ctx *ctx)
|
||||
{
|
||||
return http_response(ctx, HTTP_401_STATUS_US, NULL);
|
||||
}
|
||||
|
||||
int http_response_auth(struct http_server_ctx *ctx)
|
||||
{
|
||||
return http_response(ctx, HTTP_STATUS_200_OK,
|
||||
HTML_HEADER"<h2><center>user: "HTTP_AUTH_USERNAME
|
||||
", password: "HTTP_AUTH_PASSWORD"</center></h2>"
|
||||
HTML_FOOTER);
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2017 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _HTTP_WRITE_UTILS_H
|
||||
#define _HTTP_WRITE_UTILS_H
|
||||
|
||||
#include "http_types.h"
|
||||
#include <net/http.h>
|
||||
|
||||
/* Writes the received HTTP header fields to the client */
|
||||
int http_response_header_fields(struct http_server_ctx *ctx);
|
||||
|
||||
/* Writes an elementary It Works! HTML web page to the client */
|
||||
int http_response_it_works(struct http_server_ctx *ctx);
|
||||
|
||||
int http_response_401(struct http_server_ctx *ctx);
|
||||
|
||||
/* Writes a 200 OK HTTP status code with a 404 Not Found HTML msg */
|
||||
int http_response_soft_404(struct http_server_ctx *ctx);
|
||||
|
||||
int http_response_auth(struct http_server_ctx *ctx);
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue