35 #ifndef _AD_HTTP_HANDLER_H
36 #define _AD_HTTP_HANDLER_H
38 #include "qlibc/qlibc.h"
49 #define HTTP_PROTOCOL_09 "HTTP/0.9"
50 #define HTTP_PROTOCOL_10 "HTTP/1.0"
51 #define HTTP_PROTOCOL_11 "HTTP/1.1"
54 #define HTTP_NO_RESPONSE (0)
55 #define HTTP_CODE_CONTINUE (100)
56 #define HTTP_CODE_OK (200)
57 #define HTTP_CODE_CREATED (201)
58 #define HTTP_CODE_NO_CONTENT (204)
59 #define HTTP_CODE_PARTIAL_CONTENT (206)
60 #define HTTP_CODE_MULTI_STATUS (207)
61 #define HTTP_CODE_MOVED_TEMPORARILY (302)
62 #define HTTP_CODE_NOT_MODIFIED (304)
63 #define HTTP_CODE_BAD_REQUEST (400)
64 #define HTTP_CODE_UNAUTHORIZED (401)
65 #define HTTP_CODE_FORBIDDEN (403)
66 #define HTTP_CODE_NOT_FOUND (404)
67 #define HTTP_CODE_METHOD_NOT_ALLOWED (405)
68 #define HTTP_CODE_REQUEST_TIME_OUT (408)
69 #define HTTP_CODE_GONE (410)
70 #define HTTP_CODE_REQUEST_URI_TOO_LONG (414)
71 #define HTTP_CODE_LOCKED (423)
72 #define HTTP_CODE_INTERNAL_SERVER_ERROR (500)
73 #define HTTP_CODE_NOT_IMPLEMENTED (501)
74 #define HTTP_CODE_SERVICE_UNAVAILABLE (503)
77 #define HTTP_CRLF "\r\n"
78 #define HTTP_DEF_CONTENTTYPE "application/octet-stream"
86 #define AD_HOOK_ALL (0)
87 #define AD_HOOK_ON_CONNECT (1)
88 #define AD_HOOK_AFTER_REQUESTLINE (1 << 2)
89 #define AD_HOOK_AFTER_HEADER (1 << 3)
90 #define AD_HOOK_ON_BODY (1 << 4)
91 #define AD_HOOK_ON_REQUEST (1 << 5)
92 #define AD_HOOK_ON_CLOSE (1 << 6)
int ad_http_handler(short event, ad_conn_t *conn, void *userdata)
HTTP protocol handler hook.
size_t ad_http_get_content_length_stored(ad_conn_t *conn)
Return the actual size of data stored in in-buffer.
const char * ad_http_get_response_header(ad_conn_t *conn, const char *name)
Get response header.
struct evbuffer * ad_http_get_outbuf(ad_conn_t *conn)
enum ad_http_request_status_e ad_http_get_status(ad_conn_t *conn)
Return the request status.
size_t ad_http_send_chunk(ad_conn_t *conn, const void *data, size_t size)
off_t ad_http_get_content_length(ad_conn_t *conn)
Return the size of content from the request.
size_t ad_http_send_header(ad_conn_t *conn)
struct ad_http_s::@1 response
struct evbuffer * ad_http_get_inbuf(ad_conn_t *conn)
int ad_http_set_response_header(ad_conn_t *conn, const char *name, const char *value)
Set response header.
size_t ad_http_send_data(ad_conn_t *conn, const void *data, size_t size)
enum ad_http_request_status_e status
int ad_http_is_keepalive_request(ad_conn_t *conn)
Return whether the request is keep-alive request or not.
int ad_http_set_response_content(ad_conn_t *conn, const char *contenttype, off_t size)
size_t ad_http_response(ad_conn_t *conn, int code, const char *contenttype, const void *data, off_t size)
const char * ad_http_get_reason(int code)
const char * ad_http_get_request_header(ad_conn_t *conn, const char *name)
Get request header.
void * ad_http_get_content(ad_conn_t *conn, size_t maxsize, size_t *storedsize)
Remove content from the in-buffer.
struct ad_http_s::@0 request
int ad_http_set_response_code(ad_conn_t *conn, int code, const char *reason)