http
1.13.18
Toggle main menu visibility
Loading...
Searching...
No Matches
http_header.h
Go to the documentation of this file.
1
/*
2
* This file is part of the Sofia-SIP package
3
*
4
* Copyright (C) 2005 Nokia Corporation.
5
*
6
* Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public License
10
* as published by the Free Software Foundation; either version 2.1 of
11
* the License, or (at your option) any later version.
12
*
13
* This library is distributed in the hope that it will be useful, but
14
* WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Lesser General Public License for more details.
17
*
18
* You should have received a copy of the GNU Lesser General Public
19
* License along with this library; if not, write to the Free Software
20
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21
* 02110-1301 USA
22
*
23
*/
24
25
#ifndef HTTP_HEADER_H
27
#define HTTP_HEADER_H
28
37
38
#ifndef SU_ALLOC_H
39
#include <
sofia-sip/su_alloc.h
>
40
#endif
41
42
#ifndef SU_TAG_H
43
#include <
sofia-sip/su_tag.h
>
44
#endif
45
46
#ifndef HTTP_H
47
#include <
sofia-sip/http.h
>
48
#endif
49
50
#ifndef MSG_HEADER_H
51
#include <
sofia-sip/msg_header.h
>
52
#endif
53
54
SOFIA_BEGIN_DECLS
55
56
/* ----------------------------------------------------------------------
57
* 1) Macros
58
*/
59
61
#define HTTP_HEADER_INIT(h, http_class, size) \
62
((void)memset((h), 0, (size)), \
63
(void)(((msg_common_t *)(h))->h_class = (http_class)), \
64
(h))
65
66
#define HTTP_METHOD_NAME(method, name) \
67
((method) == http_method_unknown ? (name) : http_method_name(method, name))
68
69
/* ----------------------------------------------------------------------
70
* 2) Variables
71
*/
72
73
SOFIAPUBVAR
char
const
http_method_name_get[];
74
SOFIAPUBVAR
char
const
http_method_name_post[];
75
SOFIAPUBVAR
char
const
http_method_name_head[];
76
SOFIAPUBVAR
char
const
http_method_name_options[];
77
SOFIAPUBVAR
char
const
http_method_name_put[];
78
SOFIAPUBVAR
char
const
http_method_name_delete[];
79
SOFIAPUBVAR
char
const
http_method_name_trace[];
80
SOFIAPUBVAR
char
const
http_method_name_connect[];
81
83
SOFIAPUBVAR
char
const
http_version_0_9
[];
84
86
SOFIAPUBVAR
char
const
http_version_1_0
[];
87
89
SOFIAPUBVAR
char
const
http_version_1_1
[];
90
91
#define HTTP_VERSION_CURRENT http_version_1_1
92
93
/* ----------------------------------------------------------------------
94
* 3) Prototypes
95
*/
96
98
SOFIAPUBFUN
msg_mclass_t
const
*
http_default_mclass
(
void
);
99
101
SOFIAPUBFUN
int
http_request_complete
(
msg_t
*msg);
102
104
SOFIAPUBFUN
int
http_message_complete
(
msg_t
*msg,
http_t
*http);
105
107
SOFIAPUBFUN
int
http_add_dup
(
msg_t
*,
http_t
*,
http_header_t
const
*);
108
110
SOFIAPUBFUN
int
http_add_make
(
msg_t
*msg,
http_t
*http,
111
msg_hclass_t
*hc,
char
const
*s);
112
114
SOFIAPUBFUN
int
http_add_format
(
msg_t
*msg,
http_t
*http,
msg_hclass_t
*hc,
115
char
const
*fmt, ...);
116
118
SOFIAPUBFUN
int
http_add_tl
(
msg_t
*msg,
http_t
*http,
119
tag_type_t
tag,
tag_value_t
value, ...);
120
122
SOFIAPUBFUN
int
http_strip_hostport
(
url_t
*url);
123
125
SOFIAPUBFUN
int
http_complete_response
(
msg_t
*msg,
126
int
status,
char
const
*phrase,
127
http_t
const
*request);
128
130
SOFIAPUBFUN
char
const
*
http_method_name
(
http_method_t
method,
131
char
const
*name);
132
134
SOFIAPUBFUN
http_method_t
http_method_code
(
char
const
*name);
135
136
#if !SU_HAVE_INLINE
137
SOFIAPUBFUN
http_t
*
http_object
(
msg_t
*msg);
138
SOFIAPUBFUN
int
http_header_insert
(
msg_t
*msg,
http_t
*http,
http_header_t
*h);
139
SOFIAPUBFUN
int
http_header_remove
(
msg_t
*msg,
http_t
*http,
http_header_t
*h);
140
SOFIAPUBFUN
char
const
*
http_header_name
(
http_header_t
const
*h,
int
compact);
141
SOFIAPUBFUN
void
*
http_header_data
(
http_header_t
*h);
142
SOFIAPUBFUN
http_content_length_t *http_content_length_create(
su_home_t
*home,
143
uint32_t
n);
144
SOFIAPUBFUN
http_payload_t
*http_payload_create(
su_home_t
*home,
145
void
const
*data, usize_t len);
146
SOFIAPUBFUN
http_separator_t
*http_separator_create(
su_home_t
*home);
147
#endif
148
149
SOFIAPUBFUN
http_header_t
*http_header_format(
su_home_t
*home,
msg_hclass_t
*,
150
char
const
*fmt, ...);
151
152
154
SOFIAPUBFUN
http_request_t *
http_request_create
(
su_home_t
*home,
155
http_method_t
method,
156
const
char
*name,
157
url_string_t
const
*url,
158
char
const
*version);
159
161
SOFIAPUBFUN
http_status_t *
http_status_create
(
su_home_t
*home,
162
unsigned
status,
163
char
const
*phrase,
164
char
const
*version);
165
167
SOFIAPUBFUN
http_host_t *
http_host_create
(
su_home_t
*home,
168
char
const
*host,
169
char
const
*port);
170
172
SOFIAPUBFUN
http_date_t
*
http_date_create
(
su_home_t
*home,
http_time_t
t);
173
175
SOFIAPUBFUN
http_expires_t
*
http_expires_create
(
su_home_t
*home,
176
http_time_t
delta);
177
179
SOFIAPUBFUN
int
http_url_cmp
(
url_t
const
*a,
url_t
const
*b);
180
182
SOFIAPUBFUN
issize_t
http_query_parse
(
char
*query,
183
/* char const *key, char **return_value, */
184
...);
185
186
/* ----------------------------------------------------------------------
187
* 4) Inlined functions
188
*/
189
190
#if SU_HAVE_INLINE
192
su_inline
193
http_t
*
http_object
(
msg_t
*msg)
194
{
195
return
(
http_t
*)
msg_public
(msg,
HTTP_PROTOCOL_TAG
);
196
}
197
216
su_inline
217
int
http_header_insert
(
msg_t
*msg,
http_t
*http,
http_header_t
*h)
218
{
219
return
msg_header_insert
(msg, (
msg_pub_t
*)http, (
msg_header_t
*)h);
220
}
221
223
su_inline
224
int
http_header_remove
(
msg_t
*msg,
http_t
*http,
http_header_t
*h)
225
{
226
return
msg_header_remove
(msg, (
msg_pub_t
*)http, (
msg_header_t
*)h);
227
}
228
230
su_inline
231
char
const
*
http_header_name
(
http_header_t
const
*h,
int
compact)
232
{
233
if
(compact && h->sh_class->hc_short[0])
234
return
h->sh_class->hc_short;
235
else
236
return
h->sh_class->hc_name;
237
}
238
240
su_inline
241
void
*
http_header_data
(
http_header_t
*h)
242
{
243
return
h && h != HTTP_NONE ? h->sh_class->hc_size + (
char
*)h : NULL;
244
}
245
246
su_inline
247
http_content_length_t *http_content_length_create(
su_home_t
*home,
uint32_t
n)
248
{
249
return
msg_content_length_create
(home, n);
250
}
251
252
su_inline
253
http_payload_t
*http_payload_create(
su_home_t
*home,
void
const
*data, isize_t len)
254
{
255
return
msg_payload_create
(home, data, len);
256
}
257
258
su_inline
259
http_separator_t
*http_separator_create(
su_home_t
*home)
260
{
261
return
msg_separator_create(home);
262
}
263
#endif
264
265
SOFIA_END_DECLS
266
267
#ifndef HTTP_PROTOS_H
268
#include <
sofia-sip/http_protos.h
>
269
#endif
270
271
#endif
/* !defined(HTTP_HEADER_H) */
http_date_create
http_date_t * http_date_create(su_home_t *home, http_time_t t)
Create an Date header object.
Definition
http_basic.c:582
http_date_t
struct http_date_s http_date_t
@HTTP_HEADER http_content_type Content-Type header.
Definition
http.h:127
http_expires_t
http_date_t http_expires_t
@HTTP_HEADER http_expires Expires header.
Definition
http.h:130
msg_content_length_create
msg_content_length_t * msg_content_length_create(su_home_t *home, uint32_t n)
http.h
HTTP message, methods, headers.
HTTP_PROTOCOL_TAG
#define HTTP_PROTOCOL_TAG
HTTP protocol identifier.
Definition
http.h:62
http_method_t
http_method_t
IDs for well-known HTTP methods.
Definition
http.h:73
http_payload_t
msg_payload_t http_payload_t
Entity-body.
Definition
http.h:176
http_separator_t
msg_separator_t http_separator_t
Separator line between headers and message contents.
Definition
http.h:174
http_time_t
unsigned long http_time_t
Time in seconds since 01-Jan-1900.
Definition
http.h:178
http_t
struct http_s http_t
HTTP message object.
Definition
http.h:102
http_header_t
union http_header_u http_header_t
Any HTTP header - union of all possible HTTP headers.
Definition
http.h:105
http_method_code
http_method_t http_method_code(char const *name)
Return enum corresponding to the method name.
Definition
http_parser.c:501
http_status_create
http_status_t * http_status_create(su_home_t *home, unsigned status, char const *phrase, char const *version)
Create a status line object.
Definition
http_basic.c:261
http_version_0_9
char const http_version_0_9[]
HTTP 0.9.
Definition
http_parser.c:62
http_version_1_1
char const http_version_1_1[]
HTTP 1.1 version.
Definition
http_parser.c:58
http_add_format
int http_add_format(msg_t *msg, http_t *http, msg_hclass_t *hc, char const *fmt,...)
Add a header to the HTTP message.
Definition
http_header.c:258
http_request_create
http_request_t * http_request_create(su_home_t *home, http_method_t method, const char *name, url_string_t const *url, char const *version)
Create a request line object.
Definition
http_basic.c:145
http_method_name
char const * http_method_name(http_method_t method, char const *name)
Return string corresponding to the method.
Definition
http_parser.c:416
http_header_remove
int http_header_remove(msg_t *msg, http_t *http, http_header_t *h)
Remove a header from a HTTP message.
Definition
http_header.h:224
http_add_dup
int http_add_dup(msg_t *, http_t *, http_header_t const *)
Add a duplicate of header object to a HTTP message.
Definition
http_header.c:231
http_version_1_0
char const http_version_1_0[]
HTTP 1.0.
Definition
http_parser.c:60
http_header_insert
int http_header_insert(msg_t *msg, http_t *http, http_header_t *h)
Insert a (list of) header(s) to the header structure and fragment chain.
Definition
http_header.h:217
http_complete_response
int http_complete_response(msg_t *msg, int status, char const *phrase, http_t const *request)
Add required headers to the response message.
Definition
http_header.c:151
http_message_complete
int http_message_complete(msg_t *msg, http_t *http)
Complete a HTTP message.
Definition
http_header.c:120
http_url_cmp
int http_url_cmp(url_t const *a, url_t const *b)
Compare two HTTP URLs.
Definition
http_header.c:281
http_strip_hostport
int http_strip_hostport(url_t *url)
Remove schema, host, and port from URL.
Definition
http_header.c:99
http_add_make
int http_add_make(msg_t *msg, http_t *http, msg_hclass_t *hc, char const *s)
Add a header to the HTTP message.
Definition
http_header.c:244
http_add_tl
int http_add_tl(msg_t *msg, http_t *http, tag_type_t tag, tag_value_t value,...)
Add tagged headers to the HTTP message.
Definition
http_tag_class.c:159
http_header_data
void * http_header_data(http_header_t *h)
Return data after header structure.
Definition
http_header.h:241
http_object
http_t * http_object(msg_t *msg)
Get HTTP structure from msg.
Definition
http_header.h:193
http_default_mclass
msg_mclass_t const * http_default_mclass(void)
HTTP parser description.
Definition
http_parser.c:64
http_expires_create
http_expires_t * http_expires_create(su_home_t *home, http_time_t delta)
Create an Expires header object.
http_request_complete
int http_request_complete(msg_t *msg)
Complete a HTTP request.
Definition
http_header.c:62
http_host_create
http_host_t * http_host_create(su_home_t *home, char const *host, char const *port)
Create an Host header object.
Definition
http_basic.c:729
http_header_name
char const * http_header_name(http_header_t const *h, int compact)
Return name of the header.
Definition
http_header.h:231
http_query_parse
issize_t http_query_parse(char *query,...)
Parse query part in HTTP URL.
Definition
http_parser.c:521
http_protos.h
Macros for each HTTP header.
msg_public
msg_pub_t * msg_public(msg_t const *msg, void *tag)
msg_header.h
msg_payload_create
msg_payload_t * msg_payload_create(su_home_t *home, void const *data, usize_t len))
msg_header_insert
int msg_header_insert(msg_t *msg, msg_pub_t *mo, msg_header_t *h)
msg_header_remove
int msg_header_remove(msg_t *msg, msg_pub_t *mo, msg_header_t *h)
msg_hclass_t
struct msg_hclass_s const msg_hclass_t
msg_header_t
MSG_HDR_T msg_header_t
msg_t
struct msg_s msg_t
msg_pub_t
MSG_PUB_T msg_pub_t
msg_mclass_t
struct msg_mclass_s msg_mclass_t
url_t
su_alloc.h
su_home_t
SU_HOME_T su_home_t
SOFIAPUBFUN
#define SOFIAPUBFUN
SOFIAPUBVAR
#define SOFIAPUBVAR
su_inline
#define su_inline
su_tag.h
tag_value_t
intptr_t tag_value_t
tag_type_t
struct tag_type_s const * tag_type_t
uint32_t
SU_U32_T uint32_t
url_string_t
Sofia-SIP 1.13.18 - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.