xref: /lighttpd1.4/src/http_header.h (revision 92e5a021)
1 #ifndef INCLUDED_HTTP_HEADER_H
2 #define INCLUDED_HTTP_HEADER_H
3 #include "first.h"
4 
5 #include "base_decls.h"
6 #include "buffer.h"
7 
8 /* Note: must be kept in sync with http_header.c http_headers[] */
9 /* Note: when adding new items, must replace OTHER in existing code for item */
10 enum http_header_e {
11   HTTP_HEADER_UNSPECIFIED       = -1
12  ,HTTP_HEADER_OTHER             =  0
13  ,HTTP_HEADER_ACCEPT_ENCODING
14  ,HTTP_HEADER_AUTHORIZATION
15  ,HTTP_HEADER_CACHE_CONTROL
16  ,HTTP_HEADER_CONNECTION
17  ,HTTP_HEADER_CONTENT_ENCODING
18  ,HTTP_HEADER_CONTENT_LENGTH
19  ,HTTP_HEADER_CONTENT_LOCATION
20  ,HTTP_HEADER_CONTENT_TYPE
21  ,HTTP_HEADER_COOKIE
22  ,HTTP_HEADER_DATE
23  ,HTTP_HEADER_ETAG
24  ,HTTP_HEADER_EXPECT
25  ,HTTP_HEADER_FORWARDED
26  ,HTTP_HEADER_HOST
27  ,HTTP_HEADER_IF_MODIFIED_SINCE
28  ,HTTP_HEADER_IF_NONE_MATCH
29  ,HTTP_HEADER_LAST_MODIFIED
30  ,HTTP_HEADER_LOCATION
31  ,HTTP_HEADER_RANGE
32  ,HTTP_HEADER_SERVER
33  ,HTTP_HEADER_SET_COOKIE
34  ,HTTP_HEADER_STATUS
35  ,HTTP_HEADER_TRANSFER_ENCODING
36  ,HTTP_HEADER_UPGRADE
37  ,HTTP_HEADER_USER_AGENT
38  ,HTTP_HEADER_VARY
39  ,HTTP_HEADER_X_FORWARDED_FOR
40  ,HTTP_HEADER_X_FORWARDED_PROTO
41  ,HTTP_HEADER_HTTP2_SETTINGS
42 };
43 
44 __attribute_pure__
45 enum http_header_e http_header_hkey_get(const char *s, uint32_t slen);
46 __attribute_pure__
47 enum http_header_e http_header_hkey_get_lc(const char *s, uint32_t slen);
48 
49 __attribute_pure__
50 int http_header_str_to_code (const char * const s);
51 
52 __attribute_pure__
53 int http_header_str_contains_token (const char *s, uint32_t slen, const char *m, uint32_t mlen);
54 
55 int http_header_remove_token (buffer * const b, const char * const m, const uint32_t mlen);
56 
57 __attribute_pure__
58 buffer * http_header_response_get(const request_st *r, enum http_header_e id, const char *k, uint32_t klen);
59 void http_header_response_unset(request_st *r, enum http_header_e id, const char *k, uint32_t klen);
60 void http_header_response_set(request_st *r, enum http_header_e id, const char *k, uint32_t klen, const char *v, uint32_t vlen);
61 void http_header_response_append(request_st *r, enum http_header_e id, const char *k, uint32_t klen, const char *v, uint32_t vlen);
62 void http_header_response_insert(request_st *r, enum http_header_e id, const char *k, uint32_t klen, const char *v, uint32_t vlen);
63 
64 __attribute_pure__
65 buffer * http_header_request_get(const request_st *r, enum http_header_e id, const char *k, uint32_t klen);
66 void http_header_request_unset(request_st *r, enum http_header_e id, const char *k, uint32_t klen);
67 void http_header_request_set(request_st *r, enum http_header_e id, const char *k, uint32_t klen, const char *v, uint32_t vlen);
68 void http_header_request_append(request_st *r, enum http_header_e id, const char *k, uint32_t klen, const char *v, uint32_t vlen);
69 
70 __attribute_pure__
71 buffer * http_header_env_get(const request_st *r, const char *k, uint32_t klen);
72 void http_header_env_set(request_st *r, const char *k, uint32_t klen, const char *v, uint32_t vlen);
73 void http_header_env_append(request_st *r, const char *k, uint32_t klen, const char *v, uint32_t vlen);
74 
75 __attribute_hot__
76 uint32_t http_header_parse_hoff (const char *n, const uint32_t clen, unsigned short hoff[8192]);
77 
78 #endif
79