Httpd server.
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
#include <string.h>
#include "lwip/opt.h"
#include "lwip/tcpip.h"
#include "fs.h"
#include "httpd.h"
#include "cgi.h"
Macros | |
#define | HTTP_DEFAULT_PAGE "index.html" |
Functions | |
const char * | get_ext (const char *name) |
Get filename extension type. More... | |
static void | http_decodeUrl (const char *raw_buf, size_t raw_len, char *decodec_buf, size_t len) |
Decode URL. More... | |
static void | http_getPageName (const char *recv_buf, size_t recv_len, char *page_name, size_t len) |
Get requested page name. More... | |
int | http_getValue (char *tolenized_buf, size_t tolenized_buf_len, const char *key, char *value, size_t len) |
Get key value from tokenized buffer. More... | |
static char | http_hexToAscii (char first, char second) |
ASCII to HEX converter. More... | |
void | http_request (void *pvParameters) |
Core HTTP server function processing the request. More... | |
static int | http_searchContentType (const char *name) |
Match content type based on filename extension. More... | |
void | http_sendInternalErr (struct netconn *client, int content_type) |
Send HTTP internal server error code. More... | |
void | http_sendOk (struct netconn *client, int content_type) |
Send the HTTP header with the appropriated content type. More... | |
int | http_tokenizeGetRequest (char *raw_buf, size_t raw_len) |
Tokenize a buffer. More... | |
Variables | |
struct { | |
const char * content | |
const char * key | |
} | http_content_type [] |
static const char | http_html_hdr_200 [] = "HTTP/1.0 200 OK\r\n" |
static const char | http_html_hdr_404 [] = "HTTP/1.0 404 Not Found\r\n" |
static const char | http_html_hdr_500 [] = "HTTP/1.0 500 Internal Server Error\r\n" |
const char | http_server_error [] |
BoardStatus | status |
#define HTTP_DEFAULT_PAGE "index.html" |
Referenced by http_request().
const char* get_ext | ( | const char * | name | ) |
Get filename extension type.
name | String containing a filename. |
References NULL.
Referenced by cgi_search(), and http_searchContentType().
|
static |
Decode URL.
raw_buf | Input buffer. |
raw_len | Input buffer length. |
decodec_buf | Output decoded buffer. |
len | Output buffer length. |
References http_hexToAscii().
Referenced by http_getValue().
|
static |
Get requested page name.
recv_buf | Receive buffer. |
recv_len | Receive buffer length. |
page_name | Output buffer to store requestd page name. |
len | Output buffer length. |
Referenced by http_request().
int http_getValue | ( | char * | tolenized_buf, |
size_t | tolenized_buf_len, | ||
const char * | key, | ||
char * | value, | ||
size_t | len | ||
) |
Get key value from tokenized buffer.
References http_decodeUrl().
|
static |
ASCII to HEX converter.
first | First digit. |
second | Second digit. |
Referenced by http_decodeUrl().
Core HTTP server function processing the request.
pvParameters | Netconn socket to use. |
References cgi_search(), cgi_table, fs_file::data, ERR_OK, fs_open(), HTTP_CONTENT_HTML, HTTP_DEFAULT_PAGE, http_getPageName(), http_html_hdr_404, http_searchContentType(), http_sendInternalErr(), http_sendOk(), http_server_error, fs_file::len, netbuf_data(), netbuf_delete(), netconn_close(), NETCONN_COPY, netconn_delete(), netconn_recv(), netconn_write, NULL, and vTaskDelete().
Referenced by http_task().
|
static |
Match content type based on filename extension.
name | String containing a filename. |
References get_ext(), HTTP_CONTENT_CNT, HTTP_CONTENT_JPEG, http_content_type, and key.
Referenced by http_request().
Send HTTP internal server error code.
References content, http_content_type, http_html_hdr_500, NETCONN_COPY, and netconn_write.
Referenced by http_request().
Send the HTTP header with the appropriated content type.
client | Socket to send data to. |
content_type | Index in the http_content_type table. |
References content, http_content_type, http_html_hdr_200, NETCONN_COPY, and netconn_write.
Referenced by cgi_chipInfo(), cgi_status(), and http_request().
int http_tokenizeGetRequest | ( | char * | raw_buf, |
size_t | raw_len | ||
) |
Tokenize a buffer.
raw_buf | Buffer to parse. |
raw_len | Buffer length. |
const char* content |
Referenced by http_sendInternalErr(), and http_sendOk().
struct { ... } http_content_type[] |
Referenced by http_searchContentType(), http_sendInternalErr(), and http_sendOk().
|
static |
Referenced by http_sendOk().
|
static |
Referenced by http_request().
|
static |
Referenced by http_sendInternalErr().
const char http_server_error[] |
Referenced by http_request().
const char* key |
Referenced by http_searchContentType().
BoardStatus status |
Referenced by cgi_status(), pio_handler_process(), and smc_ecc_get_status().