http  1.13.16
http.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_H
27 #define HTTP_H
28 
40 #ifndef MSG_H
41 #include <sofia-sip/msg.h>
42 #endif
43 #ifndef URL_H
44 #include <sofia-sip/url.h>
45 #endif
46 #ifndef MSG_MIME_H
47 #include <sofia-sip/msg_mime.h>
48 #endif
49 
50 SOFIA_BEGIN_DECLS
51 
52 /* ----------------------------------------------------------------------
53  * 1) Constants
54  */
55 
56 #define HTTP_NONE ((http_header_t *)MSG_HEADER_NONE)
57 #define HTTP_DEFAULT_PORT (80)
58 #define HTTP_DEFAULT_SERV "80"
59 
61 #ifndef _MSC_VER
62 #define HTTP_PROTOCOL_TAG ((void *)0x48545450) /* 'HTTP' */
63 #else
64 #define HTTP_PROTOCOL_TAG ((void *)(UINT_PTR)0x48545450) /* 'HTTP' */
65 #endif
66 
68 enum {
69  HTTP_FLG_NO_BODY = (1 << 15)
70 };
71 
73 typedef enum {
85 
86 #define HTTP_METHOD(s) http_method_unknown, #s
87 #define HTTP_NO_METHOD http_method_unknown, NULL
88 #define HTTP_METHOD_GET http_method_get, "GET"
89 #define HTTP_METHOD_POST http_method_post, "POST"
90 #define HTTP_METHOD_HEAD http_method_head, "HEAD"
91 #define HTTP_METHOD_OPTIONS http_method_options, "OPTIONS"
92 #define HTTP_METHOD_PUT http_method_put, "PUT"
93 #define HTTP_METHOD_DELETE http_method_delete, "DELETE"
94 #define HTTP_METHOD_TRACE http_method_trace, "TRACE"
95 #define HTTP_METHOD_CONNECT http_method_connect, "CONNECT"
96 
97 /* ----------------------------------------------------------------------
98  * 2) Type declarations
99  */
100 
102 typedef struct http_s http_t;
103 
105 typedef union http_header_u http_header_t;
106 
107 typedef struct http_request_s http_request_t;
108 typedef struct http_status_s http_status_t;
110 typedef msg_accept_charset_t http_accept_charset_t;
111 typedef msg_accept_encoding_t http_accept_encoding_t;
112 typedef msg_accept_language_t http_accept_language_t;
114 typedef msg_numeric_t http_age_t;
115 typedef msg_list_t http_allow_t;
116 typedef msg_auth_info_t http_authentication_info_t;
117 typedef msg_auth_t http_authorization_t;
123 typedef msg_content_location_t http_content_location_t;
124 typedef msg_generic_t http_content_md5_t;
127 typedef struct http_date_s http_date_t;
128 typedef msg_generic_t http_etag_t;
129 typedef msg_generic_t http_expect_t;
131 typedef msg_generic_t http_from_t;
132 typedef struct http_host_s http_host_t;
136 typedef struct http_if_range_s http_if_range_t;
139 typedef struct http_location_s http_location_t;
141 typedef msg_generic_t http_mime_version_t;
142 typedef msg_list_t http_pragma_t;
143 typedef msg_auth_t http_proxy_authenticate_t;
144 typedef msg_auth_t http_proxy_authorization_t;
145 typedef struct http_range_s http_range_t;
146 typedef struct http_location_s http_referer_t;
148 typedef msg_generic_t http_server_t;
149 typedef struct http_te_s http_te_t;
150 typedef msg_list_t http_trailer_t;
152 typedef msg_list_t http_upgrade_t;
153 typedef msg_generic_t http_user_agent_t;
154 typedef msg_list_t http_vary_t;
155 typedef struct http_via_s http_via_t;
157 typedef msg_auth_t http_www_authenticate_t;
158 
160 
161 typedef msg_generic_t http_sec_websocket_key_t;
162 typedef msg_generic_t http_origin_t;
163 typedef msg_generic_t http_sec_websocket_protocol_t;
164 typedef msg_generic_t http_sec_websocket_version_t;
165 
166 typedef struct http_set_cookie_s http_set_cookie_t;
167 typedef struct http_cookie_s http_cookie_t;
168 
172 typedef msg_generic_t http_unknown_t;
178 typedef unsigned long http_time_t;
180 typedef unsigned long http_off_t;
181 
182 
183 /* ----------------------------------------------------------------------
184  * 3) Structure definitions
185  */
186 
189  msg_common_t rq_common[1];
190  http_error_t *rq_next;
191  http_method_t rq_method;
192  char const *rq_method_name;
194  char const *rq_version;
195 };
196 
199  msg_common_t st_common[1];
200  http_error_t *st_next;
201  char const *st_version;
202  int st_status;
203  char const *st_phrase;
204 };
205 
212 {
215  msg_param_t const *ai_params;
216 };
217 
220  msg_common_t cr_common[1];
221  http_error_t *cr_next;
225 };
226 
228 struct http_date_s {
229  msg_common_t d_common[1];
230  http_error_t *d_next;
232 };
233 
235 struct http_host_s {
236  msg_common_t h_common[1];
237  http_error_t *h_next;
238  char const *h_host;
239  char const *h_port;
240 };
241 
244  msg_common_t ifr_common[1];
245  http_error_t *ifr_next;
246  char const *ifr_tag;
248 };
249 
252  msg_common_t loc_common[1];
253  http_error_t *loc_next;
254  url_t loc_url[1];
255 };
256 
259  msg_common_t mf_common[1];
260  http_error_t *mf_next;
261  unsigned long mf_count;
262 };
263 
266 {
267  msg_common_t rng_common[1];
268  http_error_t *rng_next;
269  char const *rng_unit;
270  char const **rng_specs;
271 };
272 
279 };
280 
282 struct http_te_s {
285  char const *te_extension;
286  msg_param_t const *te_params;
287  char const *te_q;
288 };
289 
291 struct http_via_s {
292  msg_common_t v_common[1];
293  http_via_t *v_next;
294  char const *v_version;
295  char const *v_host;
296  char const *v_port;
297  char const *v_comment;
298 };
299 
302  msg_common_t c_common[1];
303  http_cookie_t *c_next;
304  msg_param_t const *c_params;
305  char const *c_version;
306  char const *c_name;
307  char const *c_domain;
308  char const *c_path;
309 };
310 
313  msg_common_t sc_common[1];
314  http_set_cookie_t *sc_next;
315  msg_param_t const *sc_params;
316  char const *sc_name;
317  char const *sc_version;
318  char const *sc_domain;
319  char const *sc_path;
320  char const *sc_comment;
321  char const *sc_max_age;
322  unsigned sc_secure;
323 };
324 
332 struct http_s {
335  void *http_user;
336  unsigned http_size;
343  /* === Headers start here */
345  http_accept_charset_t *http_accept_charset;
346  http_accept_encoding_t *http_accept_encoding;
347  http_accept_language_t *http_accept_language;
350  http_authentication_info_t*http_authentication_info;
351  http_authorization_t *http_authorization;
352  http_age_t *http_age;
356  http_etag_t *http_etag;
357  http_expect_t *http_expect;
359  http_from_t *http_from;
370  http_proxy_authenticate_t *http_proxy_authenticate;
371  http_proxy_authorization_t*http_proxy_authorization;
375  http_server_t *http_server;
380  http_user_agent_t *http_user_agent;
384  http_www_authenticate_t *http_www_authenticate;
390  http_sec_websocket_key_t *http_sec_websocket_key;
391  http_origin_t *http_origin;
392  http_sec_websocket_protocol_t *http_sec_websocket_protocol;
393  http_sec_websocket_version_t *http_sec_websocket_version;
395  http_mime_version_t *http_mime_version;
399  http_content_location_t *http_content_location;
400  http_content_md5_t *http_content_md5;
404  /* === Headers end here */
409 };
410 
418  msg_common_t sh_common[1];
419  struct {
420  msg_common_t shn_common;
421  http_header_t *shn_next;
422  } sh_header_next[1];
423 
424  msg_auth_t sh_auth[1];
425  msg_generic_t sh_generic[1];
426  msg_numeric_t sh_numeric[1];
427 
428  http_request_t sh_request[1];
429  http_status_t sh_status[1];
430  http_error_t sh_error[1];
431  http_unknown_t sh_unknown[1];
432  http_separator_t sh_separator[1];
433  http_payload_t sh_payload[1];
434 
435  /* Proper headers */
436  http_via_t sh_via[1];
437  http_host_t sh_host[1];
438  http_from_t sh_from[1];
439  http_referer_t sh_referer[1];
440  http_connection_t sh_connection[1];
441 
442  http_accept_t sh_accept[1];
443  http_accept_charset_t sh_accept_charset[1];
444  http_accept_encoding_t sh_accept_encoding[1];
445  http_accept_language_t sh_accept_language[1];
446  http_accept_ranges_t sh_accept_ranges[1];
447  http_allow_t sh_allow[1];
448  http_te_t sh_te[1];
449 
450  http_authentication_info_t sh_authentication_info[1];
451  http_authorization_t sh_authorization[1];
452  http_www_authenticate_t sh_www_authenticate[1];
453  http_proxy_authenticate_t sh_proxy_authenticate[1];
454  http_proxy_authorization_t sh_proxy_authorization[1];
455 
456  http_age_t sh_age[1];
457  http_cache_control_t sh_cache_control[1];
458  http_date_t sh_date[1];
459  http_expires_t sh_expires[1];
460  http_if_match_t sh_if_match[1];
461  http_if_modified_since_t sh_if_modified_since[1];
462  http_if_none_match_t sh_if_none_match[1];
463  http_if_range_t sh_if_range[1];
464  http_if_unmodified_since_t sh_if_unmodified_since[1];
465 
466  http_etag_t sh_etag[1];
467  http_expect_t sh_expect[1];
468  http_last_modified_t sh_last_modified[1];
469  http_location_t sh_location[1];
470  http_max_forwards_t sh_max_forwards[1];
471  http_pragma_t sh_pragma[1];
472  http_range_t sh_range[1];
473  http_retry_after_t sh_retry_after[1];
474  http_trailer_t sh_trailer[1];
475  http_upgrade_t sh_upgrade[1];
476  http_vary_t sh_vary[1];
477  http_warning_t sh_warning[1];
478 
479  http_user_agent_t sh_user_agent[1];
480  http_server_t sh_server[1];
481 
482  http_mime_version_t sh_mime_version[1];
483  http_content_language_t sh_content_language[1];
484  http_content_location_t sh_content_location[1];
485  http_content_md5_t sh_content_md5[1];
486  http_content_range_t sh_content_range[1];
487  http_content_encoding_t sh_content_encoding[1];
488  http_transfer_encoding_t sh_transfer_encoding[1];
489  http_content_type_t sh_content_type[1];
490  http_content_length_t sh_content_length[1];
491 
492 };
493 
494 SOFIA_END_DECLS
495 
496 #endif /* !defined(HTTP_H) */
http_date_t http_expires_t
@HTTP_HEADER http_expires Expires header.
Definition: http.h:130
http_date_t http_if_modified_since_t
@HTTP_HEADER http_if_modified_since If-Modified-Since header.
Definition: http.h:134
http_date_t http_if_unmodified_since_t
@HTTP_HEADER http_if_unmodified_since If-Unmodified-Since header.
Definition: http.h:137
http_date_t http_last_modified_t
@HTTP_HEADER http_last_modified Last-Modified header.
Definition: http.h:138
msg_accept_any_t msg_accept_charset_t
msg_accept_any_t msg_accept_encoding_t
msg_accept_any_t msg_accept_language_t
msg_generic_t msg_content_location_t
msg_error_t http_error_t
Erroneous header.
Definition: http.h:170
http_method_t
IDs for well-known HTTP methods.
Definition: http.h:73
@ http_method_trace
TRACE.
Definition: http.h:82
@ http_method_unknown
Unknown method, use method_name.
Definition: http.h:75
@ http_method_connect
CONNECT.
Definition: http.h:83
@ http_method_put
PUT.
Definition: http.h:80
@ http_method_post
POST.
Definition: http.h:77
@ http_method_delete
DELETE.
Definition: http.h:81
@ http_method_invalid
Invalid method name.
Definition: http.h:74
@ http_method_options
OPTIONS.
Definition: http.h:79
@ http_method_get
GET.
Definition: http.h:76
@ http_method_head
HEAD.
Definition: http.h:78
msg_generic_t http_unknown_t
Unknown header.
Definition: http.h:172
msg_payload_t http_payload_t
Entity-body.
Definition: http.h:176
unsigned long http_off_t
Range offset.
Definition: http.h:180
msg_separator_t http_separator_t
Separator line between headers and message contents.
Definition: http.h:174
unsigned long http_time_t
Time in seconds since 01-Jan-1900.
Definition: http.h:178
MSG_PUB_T msg_pub_t
Structure for Authentication-Info header.
Definition: http.h:212
msg_common_t ai_common[1]
Common fragment info.
Definition: http.h:213
msg_error_t * ai_next
Dummy link to next.
Definition: http.h:214
msg_param_t const * ai_params
List of authentication info.
Definition: http.h:215
Content-Range.
Definition: http.h:219
http_off_t cr_last
Last-byte-pos.
Definition: http.h:223
http_off_t cr_first
First-byte-pos.
Definition: http.h:222
http_off_t cr_length
Instance-length.
Definition: http.h:224
Date, Expires, If-Modified-Since, If-Unmodified-Since, Last-Modified.
Definition: http.h:228
http_time_t d_time
Seconds since Jan 1, 1900.
Definition: http.h:231
Host.
Definition: http.h:235
If-Range.
Definition: http.h:243
http_time_t ifr_time
Timestamp.
Definition: http.h:247
char const * ifr_tag
Tag.
Definition: http.h:246
Location, Referer.
Definition: http.h:251
Max-Forwards.
Definition: http.h:258
Range.
Definition: http.h:266
HTTP request line.
Definition: http.h:188
char const * rq_method_name
Method enum.
Definition: http.h:192
char const * rq_version
URL.
Definition: http.h:194
url_t rq_url[1]
Method name.
Definition: http.h:193
Retry-After.
Definition: http.h:274
http_time_t ra_date
When to retry.
Definition: http.h:277
msg_common_t ra_common[1]
Common fragment info.
Definition: http.h:275
http_error_t * ra_next
Link to next (dummy)
Definition: http.h:276
http_time_t ra_delta
Seconds to before retry.
Definition: http.h:278
HTTP message object.
Definition: http.h:332
http_allow_t * http_allow
Allow.
Definition: http.h:349
msg_common_t http_common[1]
For recursive inclusion.
Definition: http.h:333
http_content_length_t * http_content_length
Content-Length.
Definition: http.h:398
http_content_location_t * http_content_location
Content-Location.
Definition: http.h:399
http_content_md5_t * http_content_md5
Content-MD5.
Definition: http.h:400
http_referer_t * http_referer
Referer.
Definition: http.h:373
http_accept_ranges_t * http_accept_ranges
Accept-Ranges.
Definition: http.h:348
http_if_unmodified_since_t * http_if_unmodified_since
If-Unmodified-Since.
Definition: http.h:365
http_proxy_connection_t * http_proxy_connection
Proxy-Connection.
Definition: http.h:386
http_pragma_t * http_pragma
Pragma.
Definition: http.h:369
http_sec_websocket_version_t * http_sec_websocket_version
Sec-Websocket-Version.
Definition: http.h:393
http_mime_version_t * http_mime_version
MIME-Version.
Definition: http.h:395
unsigned http_size
Size of this structure.
Definition: http.h:336
http_status_t * http_status
Status line.
Definition: http.h:341
http_error_t * http_error
Erroneous headers.
Definition: http.h:338
http_upgrade_t * http_upgrade
Upgrade.
Definition: http.h:379
http_server_t * http_server
Server.
Definition: http.h:375
http_proxy_authenticate_t * http_proxy_authenticate
Proxy-Authenticate.
Definition: http.h:370
http_set_cookie_t * http_set_cookie
Set-Cookie.
Definition: http.h:387
http_accept_charset_t * http_accept_charset
Accept-Charset.
Definition: http.h:345
int http_flags
Flags.
Definition: http.h:337
http_content_range_t * http_content_range
Content-Range.
Definition: http.h:401
http_accept_language_t * http_accept_language
Accept-Language.
Definition: http.h:347
http_header_t * http_unknown
Unknown headers.
Definition: http.h:405
http_content_encoding_t * http_content_encoding
Content-Encoding.
Definition: http.h:396
http_host_t * http_host
Host.
Definition: http.h:360
http_cookie_t * http_cookie
Cookie.
Definition: http.h:388
http_retry_after_t * http_retry_after
Retry-After.
Definition: http.h:374
http_user_agent_t * http_user_agent
User-Agent.
Definition: http.h:380
http_accept_t * http_accept
Accept.
Definition: http.h:344
http_payload_t * http_payload
Message entity-body.
Definition: http.h:408
http_etag_t * http_etag
ETag.
Definition: http.h:356
http_origin_t * http_origin
Origin.
Definition: http.h:391
http_cache_control_t * http_cache_control
Cache-Control.
Definition: http.h:353
http_authentication_info_t * http_authentication_info
Authentication-Info.
Definition: http.h:350
http_warning_t * http_warning
Warning.
Definition: http.h:383
http_range_t * http_range
Range.
Definition: http.h:372
http_max_forwards_t * http_max_forwards
Max-Forwards.
Definition: http.h:368
http_via_t * http_via
Via.
Definition: http.h:382
http_content_language_t * http_content_language
Content-Language.
Definition: http.h:397
http_expires_t * http_expires
Expires.
Definition: http.h:358
http_proxy_authorization_t * http_proxy_authorization
Proxy-Authorization.
Definition: http.h:371
http_vary_t * http_vary
Vary.
Definition: http.h:381
http_authorization_t * http_authorization
Authorization.
Definition: http.h:351
http_accept_encoding_t * http_accept_encoding
Accept-Encoding.
Definition: http.h:346
http_request_t * http_request
Request line
Definition: http.h:340
http_expect_t * http_expect
Expect.
Definition: http.h:357
http_sec_websocket_protocol_t * http_sec_websocket_protocol
Sec-Websocket-Protocol.
Definition: http.h:392
http_last_modified_t * http_last_modified
Last-Modified.
Definition: http.h:366
http_te_t * http_te
TE.
Definition: http.h:376
http_if_match_t * http_if_match
If-Match.
Definition: http.h:361
http_age_t * http_age
Age.
Definition: http.h:352
http_if_none_match_t * http_if_none_match
If-None-Match.
Definition: http.h:363
http_if_range_t * http_if_range
If-Range.
Definition: http.h:364
void * http_user
Application data.
Definition: http.h:335
http_separator_t * http_separator
Separator between message and payload.
Definition: http.h:406
http_content_type_t * http_content_type
Content-Type.
Definition: http.h:402
msg_pub_t * http_next
Dummy pointer to next part.
Definition: http.h:334
http_from_t * http_from
From.
Definition: http.h:359
http_transfer_encoding_t * http_transfer_encoding
Transfer-Encoding.
Definition: http.h:378
http_date_t * http_date
Date.
Definition: http.h:355
http_trailer_t * http_trailer
Trailer.
Definition: http.h:377
http_location_t * http_location
Location.
Definition: http.h:367
http_connection_t * http_connection
Connection.
Definition: http.h:354
http_if_modified_since_t * http_if_modified_since
If-Modified-Since.
Definition: http.h:362
http_sec_websocket_key_t * http_sec_websocket_key
Sec-Websocket-Key.
Definition: http.h:390
http_www_authenticate_t * http_www_authenticate
WWW-Authenticate.
Definition: http.h:384
HTTP status line.
Definition: http.h:198
TE.
Definition: http.h:282
msg_param_t const * te_params
List of parameters.
Definition: http.h:286
http_te_t * te_next
Link to next t-coding.
Definition: http.h:284
char const * te_extension
Transfer-Extension.
Definition: http.h:285
msg_common_t te_common[1]
Common fragment info.
Definition: http.h:283
char const * te_q
Q-value.
Definition: http.h:287
Via.
Definition: http.h:291
Union representing any HTTP header.
Definition: http.h:417

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