From c9d21ef831725035d8636be14996a68fd79c903b Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Thu, 18 May 2017 11:52:03 +0300 Subject: [PATCH] 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 --- samples/net/http_server/src/http_server.c | 58 ------------------- samples/net/http_server/src/http_server.h | 57 ------------------ .../net/http_server/src/http_write_utils.c | 25 -------- .../net/http_server/src/http_write_utils.h | 26 --------- 4 files changed, 166 deletions(-) delete mode 100644 samples/net/http_server/src/http_server.c delete mode 100644 samples/net/http_server/src/http_server.h delete mode 100644 samples/net/http_server/src/http_write_utils.c delete mode 100644 samples/net/http_server/src/http_write_utils.h diff --git a/samples/net/http_server/src/http_server.c b/samples/net/http_server/src/http_server.c deleted file mode 100644 index 45e3eebf0bd..00000000000 --- a/samples/net/http_server/src/http_server.c +++ /dev/null @@ -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 -#include -#include - - -#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); -} diff --git a/samples/net/http_server/src/http_server.h b/samples/net/http_server/src/http_server.h deleted file mode 100644 index 0a3711fca71..00000000000 --- a/samples/net/http_server/src/http_server.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2017 Intel Corporation - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#ifndef _HTTP_SERVER_H_ -#define _HTTP_SERVER_H_ - -#include - -/* 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 diff --git a/samples/net/http_server/src/http_write_utils.c b/samples/net/http_server/src/http_write_utils.c deleted file mode 100644 index c2c1e9c398c..00000000000 --- a/samples/net/http_server/src/http_write_utils.c +++ /dev/null @@ -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 - -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"

user: "HTTP_AUTH_USERNAME - ", password: "HTTP_AUTH_PASSWORD"

" - HTML_FOOTER); -} diff --git a/samples/net/http_server/src/http_write_utils.h b/samples/net/http_server/src/http_write_utils.h deleted file mode 100644 index 3679850dcfe..00000000000 --- a/samples/net/http_server/src/http_write_utils.h +++ /dev/null @@ -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 - -/* 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