-
Notifications
You must be signed in to change notification settings - Fork 104
/
header.h
115 lines (91 loc) · 4.16 KB
/
header.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/* Cherokee
*
* Authors:
* Alvaro Lopez Ortega <alvaro@alobbs.com>
*
* Copyright (C) 2001-2011 Alvaro Lopez Ortega
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/
#if !defined (CHEROKEE_INSIDE_CHEROKEE_H) && !defined (CHEROKEE_COMPILATION)
# error "Only <cherokee/cherokee.h> can be included directly, this file may disappear or change contents."
#endif
#ifndef CHEROKEE_HEADER_PROTECTED_H
#define CHEROKEE_HEADER_PROTECTED_H
#include "buffer.h"
#include "http.h"
CHEROKEE_BEGIN_DECLS
/* NOTE:
* Keep it sync with known_headers_names of header.c
*/
typedef enum {
header_accept,
header_accept_charset,
header_accept_encoding,
header_accept_language,
header_authorization,
header_connection,
header_content_length,
header_content_type,
header_set_cookie,
header_cookie,
header_host,
header_if_modified_since,
header_if_none_match,
header_if_range,
header_keepalive,
header_location,
header_range,
header_referer,
header_transfer_encoding,
header_upgrade,
header_user_agent,
header_x_forwarded_for,
header_x_forwarded_host,
header_x_real_ip,
header_expect,
HEADER_LENGTH
} cherokee_common_header_t;
typedef enum {
header_type_request,
header_type_response,
header_type_basic
} cherokee_header_type_t;
typedef struct cherokee_header cherokee_header_t;
#define HDR(h) ((cherokee_header_t *)(h))
typedef ret_t (* cherokee_header_foreach_func_t) (cherokee_buffer_t *header, cherokee_buffer_t *content, void *data);
ret_t cherokee_header_new (cherokee_header_t **hdr, cherokee_header_type_t type);
ret_t cherokee_header_init (cherokee_header_t *hdr, cherokee_header_type_t type);
ret_t cherokee_header_free (cherokee_header_t *hdr);
ret_t cherokee_header_mrproper (cherokee_header_t *hdr);
ret_t cherokee_header_clean (cherokee_header_t *hdr);
ret_t cherokee_header_parse (cherokee_header_t *hdr, cherokee_buffer_t *buffer, cherokee_http_t *error_code);
ret_t cherokee_header_has_header (cherokee_header_t *hdr, cherokee_buffer_t *buffer, int tail_len);
ret_t cherokee_header_get_length (cherokee_header_t *hdr, cuint_t *len);
ret_t cherokee_header_foreach_unknown (cherokee_header_t *hdr, cherokee_header_foreach_func_t func, void *data);
ret_t cherokee_header_copy_request (cherokee_header_t *hdr, cherokee_buffer_t *request);
ret_t cherokee_header_copy_query_string (cherokee_header_t *hdr, cherokee_buffer_t *query_string);
ret_t cherokee_header_copy_request_w_args (cherokee_header_t *hdr, cherokee_buffer_t *request);
ret_t cherokee_header_get_request_w_args (cherokee_header_t *hdr, char **req, int *req_len);
ret_t cherokee_header_has_known (cherokee_header_t *hdr, cherokee_common_header_t header);
ret_t cherokee_header_get_known (cherokee_header_t *hdr, cherokee_common_header_t header, char **info, cuint_t *info_len);
ret_t cherokee_header_get_unknown (cherokee_header_t *hdr, const char *name, cuint_t name_len, char **header, cuint_t *header_len);
ret_t cherokee_header_copy_known (cherokee_header_t *hdr, cherokee_common_header_t header, cherokee_buffer_t *buf);
ret_t cherokee_header_copy_unknown (cherokee_header_t *hdr, const char *name, cuint_t name_len, cherokee_buffer_t *buf);
ret_t cherokee_header_copy_method (cherokee_header_t *hdr, cherokee_buffer_t *buf);
ret_t cherokee_header_copy_version (cherokee_header_t *hdr, cherokee_buffer_t *buf);
CHEROKEE_END_DECLS
#endif /* CHEROKEE_HEADER_PROTECTED_H */