20 #ifndef __TOOLS_HTTP_H 21 #define __TOOLS_HTTP_H 92 #define HTTP_HEADER_STRING(n, v) \ 93 { .type = HTTP_HEADER_STRING, .name = (n), .val.s = (v), } 100 #define HTTP_HEADER_INT(n, v) \ 101 { .type = HTTP_HEADER_INT, .name = (n), .val.i = (v), } 110 #define HTTP_ERROR(x) ((x) != HTTP_SUCCESS) 134 typedef int (*
http_reply_cb_t)(
const char *ver,
int code,
const char *msg,
void *priv);
int(* http_header_cb_t)(const char *name, const char *value, void *priv)
pointer to a callback function to process header
Definition: http.h:144
http_status_t http_reply_recv(int sockfd, http_reply_cb_t reply_cb, http_header_cb_t header_cb, void *priv)
read HTTP reply from socket and parse it
http_status_t http_request_send(int sockfd, http_method_t method, const char *path, const char *ver, http_header_t hdr[], size_t count)
send HTTP request by socket
int(* http_reply_cb_t)(const char *ver, int code, const char *msg, void *priv)
pointer to a callback function to process reply
Definition: http.h:134
http_status_t http_reply_send(int sockfd, const char *ver, int code, const char *desc, http_header_t hdr[], size_t count)
send HTTP reply to socket
int(* http_request_cb_t)(http_method_t m, const char *path, const char *ver, void *priv)
pointer to a callback function to process request
Definition: http.h:123
enum http_status http_status_t
HTTP status code.
struct http_header http_header_t
HTTP header type.
enum http_method http_method_t
HTTP methods, see rfc2616.
http_header_type
HTTP header values type.
Definition: http.h:64
#define HTTP_HEADER_STRING(n, v)
define HTTP header name with string value
Definition: http.h:92
#define HTTP_HEADER_INT(n, v)
define HTTP header name with integer value
Definition: http.h:100
http_method
HTTP methods, see rfc2616.
Definition: http.h:34
enum http_header_type http_header_type_t
HTTP header values type.
http_status
HTTP status code.
Definition: http.h:48
http_status_t http_request_recv(int sockfd, http_request_cb_t request_cb, http_header_cb_t header_cb, void *priv)
read HTTP request from socket and parse it