http.c File Reference

Simple Http server. More...

#include "http.h"
#include "hw/hw_sd.h"
#include "hw/hw_http.h"
#include "cfg/cfg_http.h"
#include <cfg/log.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Functions

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.
int http_tokenizeGetRequest (char *raw_buf, size_t raw_len)
 tokenize a buffer
void http_sendOk (struct netconn *client, int content_type)
 Send on.
void http_sendFileNotFound (struct netconn *client, int content_type)
 Send on.
void http_sendInternalErr (struct netconn *client, int content_type)
 Send on.
void http_poll (struct netconn *server)
 Http polling function.
void http_init (http_handler_t default_callback, struct HttpCGI *table)
 Init the http server.

Detailed Description

Simple Http server.

Author:
Daniele Basile <asterix@develer.com>

This simple web server read the site's pages from SD card, and manage the cases where SD is not present or page not found, using embedded pages. Quering from browser the /status page, the server return a json dictionary where are store some board status info, like board temperature, up-time, etc.

Definition in file http.c.


Function Documentation

void http_init ( http_handler_t  default_callback,
struct HttpCGI *  table 
)

Init the http server.

The simply http server call for each client request the default_callback function. The user should define this callback to manage the client request, i.e. reading site's page from SD card. The user can define the cgi_table, where associate one callback to the user string. In this way the user could filter some client request and redirect they to custom callback, i.e. the client could request status of the device only loading the particular page name.

Parameters:
default_callbackfuction that server call for all request, that does'nt match cgi table.
tableof callcack to call when client request a particular page.

Definition at line 402 of file http.c.

void http_poll ( struct netconn *  server)

Http polling function.

Call this functions to process each client connections.

Definition at line 346 of file http.c.

void http_sendFileNotFound ( struct netconn *  client,
int  content_type 
)

Send on.

Parameters:
clientsocket the 404 File not found http header with select
content_type

Definition at line 272 of file http.c.

void http_sendInternalErr ( struct netconn *  client,
int  content_type 
)

Send on.

Parameters:
clientsocket the 500 internal server error http header with select
content_type

Definition at line 285 of file http.c.

void http_sendOk ( struct netconn *  client,
int  content_type 
)

Send on.

Parameters:
clientsocket the 200 Ok http header with select
content_type

Definition at line 258 of file http.c.