sofia-sip/http.h

Go to the documentation of this file.
00001 /*
00002  * This file is part of the Sofia-SIP package
00003  *
00004  * Copyright (C) 2005 Nokia Corporation.
00005  *
00006  * Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public License
00010  * as published by the Free Software Foundation; either version 2.1 of
00011  * the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00021  * 02110-1301 USA
00022  *
00023  */
00024 
00025 #ifndef HTTP_H
00026 
00027 #define HTTP_H
00028 
00040 #ifndef MSG_H
00041 #include <sofia-sip/msg.h>
00042 #endif
00043 #ifndef URL_H
00044 #include <sofia-sip/url.h>
00045 #endif
00046 #ifndef MSG_MIME_H
00047 #include <sofia-sip/msg_mime.h>
00048 #endif
00049 
00050 SOFIA_BEGIN_DECLS
00051 
00052 /* ----------------------------------------------------------------------
00053  * 1) Constants 
00054  */
00055 
00056 #define HTTP_NONE ((http_header_t *)MSG_HEADER_NONE)
00057 #define HTTP_DEFAULT_PORT (80)
00058 #define HTTP_DEFAULT_SERV "80"
00059 
00061 #define HTTP_PROTOCOL_TAG   ((void *)0x48545450)        /* 'HTTP' */
00062 
00064 enum {
00065   HTTP_FLG_NO_BODY = (1 << 15)
00066 };
00067 
00069 typedef enum {
00070   http_method_invalid = -1,     
00071   http_method_unknown = 0,      
00072   http_method_get,              
00073   http_method_post,             
00074   http_method_head,             
00075   http_method_options,          
00076   http_method_put,              
00077   http_method_delete,           
00078   http_method_trace,            
00079   http_method_connect,          
00080 } http_method_t;
00081 
00082 #define HTTP_METHOD(s)          http_method_unknown, #s
00083 #define HTTP_NO_METHOD          http_method_unknown, NULL
00084 #define HTTP_METHOD_GET         http_method_get, "GET"
00085 #define HTTP_METHOD_POST        http_method_post, "POST"
00086 #define HTTP_METHOD_HEAD        http_method_head, "HEAD"
00087 #define HTTP_METHOD_OPTIONS     http_method_options, "OPTIONS"
00088 #define HTTP_METHOD_PUT         http_method_put, "PUT"
00089 #define HTTP_METHOD_DELETE      http_method_delete, "DELETE"
00090 #define HTTP_METHOD_TRACE       http_method_trace, "TRACE"
00091 #define HTTP_METHOD_CONNECT     http_method_connect, "CONNECT"
00092 
00093 /* ----------------------------------------------------------------------
00094  * 2) Type declarations
00095  */
00096 
00098 typedef struct http_s               http_t;
00099 
00101 typedef union http_header_u         http_header_t;
00102 
00103 typedef struct http_request_s       http_request_t;
00104 typedef struct http_status_s        http_status_t;
00105 typedef msg_accept_t                http_accept_t;
00106 typedef msg_accept_charset_t        http_accept_charset_t;
00107 typedef msg_accept_encoding_t       http_accept_encoding_t;
00108 typedef msg_accept_language_t       http_accept_language_t;
00109 typedef msg_list_t                  http_accept_ranges_t;
00110 typedef msg_numeric_t               http_age_t;
00111 typedef msg_list_t                  http_allow_t;
00112 typedef 
00113 struct http_authentication_info_s   http_authentication_info_t;
00114 typedef msg_auth_t                  http_authorization_t;
00115 typedef msg_list_t                  http_cache_control_t;
00116 typedef msg_list_t                  http_connection_t;
00117 typedef msg_content_encoding_t      http_content_encoding_t;
00118 typedef msg_content_language_t      http_content_language_t;
00119 typedef msg_content_length_t        http_content_length_t;
00120 typedef msg_content_location_t      http_content_location_t;
00121 typedef msg_generic_t               http_content_md5_t;
00122 typedef struct http_content_range_s http_content_range_t;
00123 typedef msg_content_type_t          http_content_type_t;
00124 typedef struct http_date_s          http_date_t;
00125 typedef msg_generic_t               http_etag_t;
00126 typedef msg_generic_t               http_expect_t;
00127 typedef http_date_t                 http_expires_t;
00128 typedef msg_generic_t               http_from_t;
00129 typedef struct http_host_s          http_host_t;
00130 typedef msg_list_t                  http_if_match_t;
00131 typedef http_date_t                 http_if_modified_since_t;
00132 typedef msg_list_t                  http_if_none_match_t;
00133 typedef struct http_if_range_s      http_if_range_t;
00134 typedef http_date_t                 http_if_unmodified_since_t;
00135 typedef http_date_t                 http_last_modified_t;
00136 typedef struct http_location_s      http_location_t;
00137 typedef struct http_max_forwards_s  http_max_forwards_t;
00138 typedef msg_generic_t               http_mime_version_t;
00139 typedef msg_list_t                  http_pragma_t;
00140 typedef msg_auth_t                  http_proxy_authenticate_t;
00141 typedef msg_auth_t                  http_proxy_authorization_t;
00142 typedef struct http_range_s         http_range_t;
00143 typedef struct http_location_s      http_referer_t;
00144 typedef struct http_retry_after_s   http_retry_after_t;
00145 typedef msg_generic_t               http_server_t;
00146 typedef struct http_te_s            http_te_t;
00147 typedef msg_list_t                  http_trailer_t;
00148 typedef msg_list_t                  http_transfer_encoding_t;
00149 typedef msg_list_t                  http_upgrade_t;
00150 typedef msg_generic_t               http_user_agent_t;
00151 typedef msg_list_t                  http_vary_t;
00152 typedef struct http_via_s           http_via_t;
00153 typedef msg_warning_t               http_warning_t;
00154 typedef msg_auth_t                  http_www_authenticate_t;
00155 
00156 typedef msg_list_t                  http_proxy_connection_t;
00157 
00158 typedef struct http_set_cookie_s    http_set_cookie_t;
00159 typedef struct http_cookie_s        http_cookie_t;
00160 
00162 typedef msg_error_t                 http_error_t;
00164 typedef msg_generic_t               http_unknown_t;
00166 typedef msg_separator_t             http_separator_t;
00168 typedef msg_payload_t               http_payload_t;
00170 typedef unsigned long               http_time_t;
00172 typedef unsigned long               http_off_t;
00173 
00174 
00175 /* ----------------------------------------------------------------------
00176  * 3) Structure definitions
00177  */
00178 
00180 struct http_request_s {
00181   msg_common_t      rq_common[1];
00182   http_error_t     *rq_next;
00183   http_method_t     rq_method;          
00184   char const       *rq_method_name;     
00185   url_t             rq_url[1];          
00186   char const       *rq_version;         
00187 };
00188 
00190 struct http_status_s {
00191   msg_common_t      st_common[1];
00192   http_error_t     *st_next;
00193   char const       *st_version;
00194   int               st_status;
00195   char const       *st_phrase;
00196 };
00197 
00201 struct http_authentication_info_s
00202 {
00203   msg_common_t        ai_common[1]; 
00204   msg_error_t        *ai_next;      
00205   msg_param_t const  *ai_params;    
00206 };
00207 
00209 struct http_content_range_s {
00210   msg_common_t      cr_common[1];
00211   http_error_t     *cr_next;
00212   http_off_t        cr_first;   
00213   http_off_t        cr_last;    
00214   http_off_t        cr_length;  
00215 };
00216 
00218 struct http_date_s {
00219   msg_common_t      d_common[1];
00220   http_error_t     *d_next;
00221   http_time_t       d_time;     
00222 };
00223 
00225 struct http_host_s {
00226   msg_common_t         h_common[1];
00227   http_error_t        *h_next;
00228   char const          *h_host;
00229   char const          *h_port;
00230 };
00231 
00233 struct http_if_range_s {
00234   msg_common_t         ifr_common[1];
00235   http_error_t        *ifr_next;
00236   char const          *ifr_tag;  
00237   http_time_t          ifr_time; 
00238 };
00239 
00241 struct http_location_s {
00242   msg_common_t         loc_common[1];
00243   http_error_t        *loc_next;
00244   url_t                loc_url[1];
00245 };
00246 
00248 struct http_max_forwards_s {
00249   msg_common_t         mf_common[1];
00250   http_error_t        *mf_next;
00251   unsigned long        mf_count;
00252 };
00253 
00255 struct http_range_s
00256 {
00257   msg_common_t         rng_common[1];
00258   http_error_t        *rng_next;
00259   char const          *rng_unit;
00260   char const         **rng_specs;
00261 };
00262 
00264 struct http_retry_after_s {
00265   msg_common_t         ra_common[1];    
00266   http_error_t        *ra_next;         
00267   http_time_t          ra_date;         
00268   http_time_t          ra_delta;        
00269 };
00270 
00272 struct http_te_s {
00273   msg_common_t         te_common[1];    
00274   http_te_t           *te_next;         
00275   char const          *te_extension;    
00276   msg_param_t const   *te_params;       
00277   char const          *te_q;            
00278 };
00279 
00281 struct http_via_s {
00282   msg_common_t         v_common[1];
00283   http_via_t          *v_next;
00284   char const          *v_version;
00285   char const          *v_host;
00286   char const          *v_port;
00287   char const          *v_comment;
00288 };
00289 
00291 struct http_cookie_s {
00292   msg_common_t         c_common[1];
00293   http_cookie_t       *c_next;
00294   msg_param_t const   *c_params;
00295   char const          *c_version;
00296   char const          *c_name;
00297   char const          *c_domain;
00298   char const          *c_path;
00299 };
00300 
00302 struct http_set_cookie_s {
00303   msg_common_t         sc_common[1];
00304   http_set_cookie_t   *sc_next;
00305   msg_param_t const   *sc_params;
00306   char const          *sc_name;
00307   char const          *sc_version;
00308   char const          *sc_domain;
00309   char const          *sc_path;
00310   char const          *sc_comment;
00311   char const          *sc_max_age;
00312   unsigned             sc_secure;
00313 };
00314 
00322 struct http_s {
00323   msg_common_t               http_common[1];    
00324   msg_pub_t                 *http_next;      
00325   void                      *http_user;                
00326   unsigned                   http_size;          
00327   int                        http_flags;                          
00328   http_error_t              *http_error;              
00330   http_request_t            *http_request;                
00331   http_status_t             *http_status;                   
00333   /* === Headers start here */
00334   http_accept_t             *http_accept;                        
00335   http_accept_charset_t     *http_accept_charset;        
00336   http_accept_encoding_t    *http_accept_encoding;      
00337   http_accept_language_t    *http_accept_language;      
00338   http_accept_ranges_t      *http_accept_ranges;          
00339   http_allow_t              *http_allow;                          
00340   http_authentication_info_t*http_authentication_info;
00341   http_authorization_t      *http_authorization;          
00342   http_age_t                *http_age;                              
00343   http_cache_control_t      *http_cache_control;          
00344   http_connection_t         *http_connection;                
00345   http_date_t               *http_date;                            
00346   http_etag_t               *http_etag;                            
00347   http_expect_t             *http_expect;                        
00348   http_expires_t            *http_expires;                      
00349   http_from_t               *http_from;                            
00350   http_host_t               *http_host;                            
00351   http_if_match_t           *http_if_match;                    
00352   http_if_modified_since_t  *http_if_modified_since;  
00353   http_if_none_match_t      *http_if_none_match;          
00354   http_if_range_t           *http_if_range;                    
00355   http_if_unmodified_since_t*http_if_unmodified_since;
00356   http_last_modified_t      *http_last_modified;          
00357   http_location_t           *http_location;                    
00358   http_max_forwards_t       *http_max_forwards;            
00359   http_pragma_t             *http_pragma;                        
00360   http_proxy_authenticate_t *http_proxy_authenticate;
00361   http_proxy_authorization_t*http_proxy_authorization;
00362   http_range_t              *http_range;                          
00363   http_referer_t            *http_referer;                      
00364   http_retry_after_t        *http_retry_after;              
00365   http_server_t             *http_server;                        
00366   http_te_t                 *http_te;                                
00367   http_trailer_t            *http_trailer;                      
00368   http_transfer_encoding_t  *http_transfer_encoding;  
00369   http_upgrade_t            *http_upgrade;                      
00370   http_user_agent_t         *http_user_agent;                
00371   http_vary_t               *http_vary;                            
00372   http_via_t                *http_via;                              
00373   http_warning_t            *http_warning;                      
00374   http_www_authenticate_t   *http_www_authenticate;    
00376   http_proxy_connection_t   *http_proxy_connection;    
00377   http_set_cookie_t         *http_set_cookie;                
00378   http_cookie_t             *http_cookie;                        
00380   http_mime_version_t       *http_mime_version;            
00381   http_content_encoding_t   *http_content_encoding;    
00382   http_content_language_t   *http_content_language;    
00383   http_content_length_t     *http_content_length;        
00384   http_content_location_t   *http_content_location;    
00385   http_content_md5_t        *http_content_md5;              
00386   http_content_range_t      *http_content_range;          
00387   http_content_type_t       *http_content_type;            
00389   /* === Headers end here */
00390   http_header_t             *http_unknown;             
00391   http_separator_t          *http_separator;     
00393   http_payload_t            *http_payload;          
00394 };
00395 
00402 union http_header_u {
00403   msg_common_t                sh_common[1]; 
00404   struct {
00405     msg_common_t              shn_common;
00406     http_header_t            *shn_next;
00407   }                           sh_header_next[1];
00408 
00409   msg_auth_t                  sh_auth[1];
00410   msg_generic_t               sh_generic[1];
00411   msg_numeric_t               sh_numeric[1];
00412 
00413   http_request_t              sh_request[1];
00414   http_status_t               sh_status[1];
00415   http_error_t                sh_error[1];
00416   http_unknown_t              sh_unknown[1];
00417   http_separator_t            sh_separator[1];
00418   http_payload_t              sh_payload[1];
00419 
00420   /* Proper headers */
00421   http_via_t                 sh_via[1];
00422   http_host_t                sh_host[1];
00423   http_from_t                sh_from[1];
00424   http_referer_t             sh_referer[1];
00425   http_connection_t          sh_connection[1];
00426 
00427   http_accept_t              sh_accept[1];
00428   http_accept_charset_t      sh_accept_charset[1];
00429   http_accept_encoding_t     sh_accept_encoding[1];
00430   http_accept_language_t     sh_accept_language[1];
00431   http_accept_ranges_t       sh_accept_ranges[1];
00432   http_allow_t               sh_allow[1];
00433   http_te_t                  sh_te[1];
00434 
00435   http_authentication_info_t sh_authentication_info[1];
00436   http_authorization_t       sh_authorization[1];
00437   http_www_authenticate_t    sh_www_authenticate[1];
00438   http_proxy_authenticate_t  sh_proxy_authenticate[1];
00439   http_proxy_authorization_t sh_proxy_authorization[1];
00440 
00441   http_age_t                 sh_age[1];
00442   http_cache_control_t       sh_cache_control[1];
00443   http_date_t                sh_date[1];
00444   http_expires_t             sh_expires[1];
00445   http_if_match_t            sh_if_match[1];
00446   http_if_modified_since_t   sh_if_modified_since[1];
00447   http_if_none_match_t       sh_if_none_match[1];
00448   http_if_range_t            sh_if_range[1];
00449   http_if_unmodified_since_t sh_if_unmodified_since[1];
00450 
00451   http_etag_t                sh_etag[1];
00452   http_expect_t              sh_expect[1];
00453   http_last_modified_t       sh_last_modified[1];
00454   http_location_t            sh_location[1];
00455   http_max_forwards_t        sh_max_forwards[1];
00456   http_pragma_t              sh_pragma[1];
00457   http_range_t               sh_range[1];
00458   http_retry_after_t         sh_retry_after[1];
00459   http_trailer_t             sh_trailer[1];
00460   http_upgrade_t             sh_upgrade[1];
00461   http_vary_t                sh_vary[1];
00462   http_warning_t             sh_warning[1];
00463 
00464   http_user_agent_t          sh_user_agent[1];
00465   http_server_t              sh_server[1];
00466 
00467   http_mime_version_t        sh_mime_version[1];
00468   http_content_language_t    sh_content_language[1];
00469   http_content_location_t    sh_content_location[1];
00470   http_content_md5_t         sh_content_md5[1];
00471   http_content_range_t       sh_content_range[1];
00472   http_content_encoding_t    sh_content_encoding[1];
00473   http_transfer_encoding_t   sh_transfer_encoding[1];
00474   http_content_type_t        sh_content_type[1];
00475   http_content_length_t      sh_content_length[1];
00476 
00477 };
00478 
00479 SOFIA_END_DECLS
00480 
00481 #endif /* !defined(HTTP_H) */

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