Contiki 3.x
http-server.h
1 #ifndef HTTPSERVER_H_
2 #define HTTPSERVER_H_
3 
4 #include "http-common.h"
5 #include "rest.h"
6 
7 /*Declare process*/
8 PROCESS_NAME(http_server);
9 
10 /*Type definition of the service callback*/
11 typedef int (*service_callback) (http_request_t* request, http_response_t* response);
12 
13 /*
14  *Setter of the service callback, this callback will be called in case of HTTP request.
15  */
16 void http_set_service_callback(service_callback callback);
17 
18 /*
19  * Setter for the status code (200, 201, etc) of the response.
20  */
21 void http_set_status(http_response_t* response, status_code_t status);
22 
23 /*
24  * Adds the header name and value provided to the response.
25  * Name of the header should be hardcoded since it is accessed from code segment
26  * (not copied to buffer) whereas value of the header can be copied
27  * depending on the relevant parameter. This is needed since some values may be
28  * generated dynamically (ex: e-tag value)
29  */
30 int http_set_res_header(http_response_t* response, const char* name, const char* value, int copy);
31 
32 /*
33  * Returns the value of the header name provided. Return NULL if header does not exist.
34  */
35 const char* http_get_req_header(http_request_t* request, const char* name);
36 
37 int http_set_res_payload(http_response_t* response, uint8_t* payload, uint16_t size);
38 
39 /*
40  * Returns query variable in the URL.
41  * Returns true if the variable found, false otherwise.
42  * Variable is put in the buffer provided.
43  */
44 int http_get_query_variable(http_request_t* request, const char *name, char* output, uint16_t output_size);
45 
46 /*
47  * Returns variable in the Post Data.
48  * Returns true if the variable found, false otherwise.
49  * Variable is put in the buffer provided.
50  */
51 int http_get_post_variable(http_request_t* request, const char *name, char* output, uint16_t output_size);
52 
53 /*
54  * Get the header "Content-Type".
55  */
56 const char* http_get_content_type_string(content_type_t content_type);
57 content_type_t http_get_header_content_type(http_request_t* request);
58 
59 #endif /*HTTPSERVER_H_*/
#define PROCESS_NAME(name)
Declare the name of a process.
Definition: process.h:286