http 1.12.11devel
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
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
52#endif
53
54SOFIA_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
73SOFIAPUBVAR char const http_method_name_get[];
74SOFIAPUBVAR char const http_method_name_post[];
75SOFIAPUBVAR char const http_method_name_head[];
76SOFIAPUBVAR char const http_method_name_options[];
77SOFIAPUBVAR char const http_method_name_put[];
78SOFIAPUBVAR char const http_method_name_delete[];
79SOFIAPUBVAR char const http_method_name_trace[];
80SOFIAPUBVAR char const http_method_name_connect[];
81
83SOFIAPUBVAR char const http_version_0_9[];
84
86SOFIAPUBVAR char const http_version_1_0[];
87
89SOFIAPUBVAR char const http_version_1_1[];
90
91#define HTTP_VERSION_CURRENT http_version_1_1
92
93/* ----------------------------------------------------------------------
94 * 3) Prototypes
95 */
96
99
102
105
108
110SOFIAPUBFUN int http_add_make(msg_t *msg, http_t *http,
111 msg_hclass_t *hc, char const *s);
112
115 char const *fmt, ...);
116
118SOFIAPUBFUN int http_add_tl(msg_t *msg, http_t *http,
119 tag_type_t tag, tag_value_t value, ...);
120
123
126 int status, char const *phrase,
127 http_t const *request);
128
131 char const *name);
132
135
136#if !SU_HAVE_INLINE
140SOFIAPUBFUN char const *http_header_name(http_header_t const *h, int compact);
142SOFIAPUBFUN http_content_length_t *http_content_length_create(su_home_t *home,
143 uint32_t n);
144SOFIAPUBFUN http_payload_t *http_payload_create(su_home_t *home,
145 void const *data, usize_t len);
146SOFIAPUBFUN http_separator_t *http_separator_create(su_home_t *home);
147#endif
148
149SOFIAPUBFUN http_header_t *http_header_format(su_home_t *home, msg_hclass_t *,
150 char const *fmt, ...);
151
152
155 http_method_t method,
156 const char *name,
157 url_string_t const *url,
158 char const *version);
159
162 unsigned status,
163 char const *phrase,
164 char const *version);
165
168 char const *host,
169 char const *port);
170
173
176 http_time_t delta);
177
179SOFIAPUBFUN int http_url_cmp(url_t const *a, url_t const *b);
180
182SOFIAPUBFUN 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
194{
195 return (http_t *)msg_public(msg, HTTP_PROTOCOL_TAG);
196}
197
218{
219 return msg_header_insert(msg, (msg_pub_t *)http, (msg_header_t *)h);
220}
221
225{
226 return msg_header_remove(msg, (msg_pub_t *)http, (msg_header_t *)h);
227}
228
231char 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
242{
243 return h && h != HTTP_NONE ? h->sh_class->hc_size + (char *)h : NULL;
244}
245
247http_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
253http_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
259http_separator_t *http_separator_create(su_home_t *home)
260{
261 return msg_separator_create(home);
262}
263#endif
264
265SOFIA_END_DECLS
266
267#ifndef HTTP_PROTOS_H
269#endif
270
271#endif /* !defined(HTTP_HEADER_H) */
http_date_t * http_date_create(su_home_t *home, http_time_t t)
Create an Date header object.
Definition http_basic.c:584
msg_content_length_t * msg_content_length_create(su_home_t *, uint32_t n)
HTTP message, methods, headers.
#define HTTP_PROTOCOL_TAG
HTTP protocol identifier.
Definition http.h:61
http_method_t
IDs for well-known HTTP methods.
Definition http.h:69
msg_payload_t http_payload_t
Entity-body.
Definition http.h:167
msg_separator_t http_separator_t
Separator line between headers and message contents.
Definition http.h:165
unsigned long http_time_t
Time in seconds since 01-Jan-1900.
Definition http.h:169
http_method_t http_method_code(char const *name)
Return enum corresponding to the method name.
Definition http_parser.c:500
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:262
char const http_version_0_9[]
HTTP 0.9.
Definition http_parser.c:62
char const http_version_1_1[]
HTTP 1.1 version.
Definition http_parser.c:58
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_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
char const * http_method_name(http_method_t method, char const *name)
Return string corresponding to the method.
Definition http_parser.c:416
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
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
char const http_version_1_0[]
HTTP 1.0.
Definition http_parser.c:60
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
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
int http_message_complete(msg_t *msg, http_t *http)
Complete a HTTP message.
Definition http_header.c:120
int http_url_cmp(url_t const *a, url_t const *b)
Compare two HTTP URLs.
Definition http_header.c:281
int http_strip_hostport(url_t *url)
Remove schema, host, and port from URL.
Definition http_header.c:99
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
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
void * http_header_data(http_header_t *h)
Return data after header structure.
Definition http_header.h:241
http_t * http_object(msg_t *msg)
Get HTTP structure from msg.
Definition http_header.h:193
msg_mclass_t const * http_default_mclass(void)
HTTP parser description.
Definition http_parser.c:64
http_expires_t * http_expires_create(su_home_t *home, http_time_t delta)
Create an Expires header object.
int http_request_complete(msg_t *msg)
Complete a HTTP request.
Definition http_header.c:62
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:733
char const * http_header_name(http_header_t const *h, int compact)
Return name of the header.
Definition http_header.h:231
issize_t http_query_parse(char *query,...)
Parse query part in HTTP URL.
Definition http_parser.c:520
Macros for each HTTP header.
msg_pub_t * msg_public(msg_t const *msg, void *tag)
msg_payload_t * msg_payload_create(su_home_t *home, void const *data, usize_t len))
int msg_header_insert(msg_t *msg, msg_pub_t *mo, msg_header_t *h)
int msg_header_remove(msg_t *msg, msg_pub_t *mo, msg_header_t *h)
struct msg_hclass_s const msg_hclass_t
MSG_HDR_T msg_header_t
MSG_PUB_T msg_pub_t
Date, Expires, If-Modified-Since, If-Unmodified-Since, Last-Modified.
Definition http.h:219
Host.
Definition http.h:226
HTTP request line.
Definition http.h:179
HTTP message object.
Definition http.h:323
HTTP status line.
Definition http.h:189
SU_HOME_T su_home_t
#define SOFIAPUBFUN
#define SOFIAPUBVAR
#define su_inline
intptr_t tag_value_t
struct tag_type_s const * tag_type_t
SU_U32_T uint32_t
Union representing any HTTP header.
Definition http.h:403

Sofia-SIP 1.12.11devel - Copyright (C) 2006 Nokia Corporation. All rights reserved. Licensed under the terms of the GNU Lesser General Public License.