sofia-sip/http_header.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_HEADER_H
00026 
00027 #define HTTP_HEADER_H
00028 
00038 #ifndef SU_ALLOC_H
00039 #include <sofia-sip/su_alloc.h>
00040 #endif
00041 
00042 #ifndef SU_TAG_H
00043 #include <sofia-sip/su_tag.h>
00044 #endif
00045 
00046 #ifndef HTTP_H
00047 #include <sofia-sip/http.h>
00048 #endif
00049 
00050 #ifndef MSG_HEADER_H
00051 #include <sofia-sip/msg_header.h>
00052 #endif
00053 
00054 SOFIA_BEGIN_DECLS
00055 
00056 /* ----------------------------------------------------------------------
00057  * 1) Macros
00058  */
00059 
00061 #define HTTP_HEADER_INIT(h, http_class, size) \
00062   (memset((h), 0, (size)), ((msg_common_t *)(h))->h_class = (http_class), (h))
00063 
00064 #define HTTP_METHOD_NAME(method, name) \
00065  ((method) == http_method_unknown ? (name) : http_method_name(method, name))
00066 
00067 /* ----------------------------------------------------------------------
00068  * 2) Variables
00069  */
00070 
00071 SOFIAPUBVAR char const http_method_name_get[];
00072 SOFIAPUBVAR char const http_method_name_post[];
00073 SOFIAPUBVAR char const http_method_name_head[];
00074 SOFIAPUBVAR char const http_method_name_options[];
00075 SOFIAPUBVAR char const http_method_name_put[];
00076 SOFIAPUBVAR char const http_method_name_delete[];
00077 SOFIAPUBVAR char const http_method_name_trace[];
00078 SOFIAPUBVAR char const http_method_name_connect[];
00079 
00081 SOFIAPUBVAR char const http_version_0_9[];
00082 
00084 SOFIAPUBVAR char const http_version_1_0[];
00085 
00087 SOFIAPUBVAR char const http_version_1_1[];
00088 
00089 #define HTTP_VERSION_CURRENT http_version_1_1
00090 
00091 /* ----------------------------------------------------------------------
00092  * 3) Prototypes 
00093  */
00094 
00096 SOFIAPUBFUN msg_mclass_t *http_default_mclass(void);
00097 
00099 SOFIAPUBFUN int http_request_complete(msg_t *msg);
00100 
00102 SOFIAPUBFUN int http_message_complete(msg_t *msg, http_t *http);
00103 
00105 SOFIAPUBFUN int http_add_dup(msg_t *, http_t *, http_header_t const *);
00106 
00108 SOFIAPUBFUN int http_add_make(msg_t *msg, http_t *http,
00109                               msg_hclass_t *hc, char const *s);
00110 
00112 SOFIAPUBFUN int http_add_format(msg_t *msg, http_t *http, msg_hclass_t *hc,
00113                                 char const *fmt, ...);
00114 
00116 SOFIAPUBFUN int http_add_tl(msg_t *msg, http_t *http,
00117                             tag_type_t tag, tag_value_t value, ...);
00118 
00120 SOFIAPUBFUN int http_strip_hostport(url_t *url);
00121 
00123 SOFIAPUBFUN int http_complete_response(msg_t *msg,
00124                                        int status, char const *phrase, 
00125                                        http_t const *request);
00126 
00128 SOFIAPUBFUN char const *http_method_name(http_method_t method,
00129                                          char const *name);
00130 
00132 SOFIAPUBFUN http_method_t http_method_code(char const *name);
00133 
00134 #if !SU_HAVE_INLINE
00135 SOFIAPUBFUN http_t *http_object(msg_t *msg);
00136 SOFIAPUBFUN int http_header_insert(msg_t *msg, http_t *http, http_header_t *h);
00137 SOFIAPUBFUN int http_header_remove(msg_t *msg, http_t *http, http_header_t *h);
00138 SOFIAPUBFUN char const *http_header_name(http_header_t const *h, int compact);
00139 SOFIAPUBFUN void *http_header_data(http_header_t *h);
00140 SOFIAPUBFUN http_content_length_t *http_content_length_create(su_home_t *home, 
00141                                                               uint32_t n);
00142 SOFIAPUBFUN http_payload_t *http_payload_create(su_home_t *home, 
00143                                                 void const *data, int len);
00144 SOFIAPUBFUN http_separator_t *http_separator_create(su_home_t *home);
00145 #endif
00146 
00147 SOFIAPUBFUN http_header_t *http_header_format(su_home_t *home, msg_hclass_t *,
00148                                               char const *fmt, ...);
00149 
00150 
00152 SOFIAPUBFUN http_request_t *http_request_create(su_home_t *home,
00153                                                 http_method_t method,
00154                                                 const char *name,
00155                                                 url_string_t const *url,
00156                                                 char const *version);
00157 
00159 SOFIAPUBFUN http_status_t *http_status_create(su_home_t *home,
00160                                               unsigned status,
00161                                               char const *phrase,
00162                                               char const *version);
00163 
00165 SOFIAPUBFUN http_host_t *http_host_create(su_home_t *home, 
00166                                           char const *host,
00167                                           char const *port);
00168 
00170 SOFIAPUBFUN http_date_t *http_date_create(su_home_t *home, http_time_t t);
00171 
00173 SOFIAPUBFUN http_expires_t *http_expires_create(su_home_t *home,
00174                                                 http_time_t delta);
00175 
00177 SOFIAPUBFUN int http_url_cmp(url_t const *a, url_t const *b);
00178 
00180 SOFIAPUBFUN int http_query_parse(char *query,
00181                                  /* char const *key, char **return_value, */
00182                                  ...);
00183 
00184 /* ----------------------------------------------------------------------
00185  * 4) Inlined functions 
00186  */
00187 
00188 #if SU_HAVE_INLINE
00189 
00190 su_inline
00191 http_t *http_object(msg_t *msg)
00192 {
00193   return (http_t *)msg_public(msg, HTTP_PROTOCOL_TAG);
00194 }
00195 
00214 su_inline 
00215 int http_header_insert(msg_t *msg, http_t *http, http_header_t *h)
00216 {
00217   return msg_header_insert(msg, (msg_pub_t *)http, (msg_header_t *)h);
00218 }
00219 
00221 su_inline
00222 int http_header_remove(msg_t *msg, http_t *http, http_header_t *h)
00223 {
00224   return msg_header_remove(msg, (msg_pub_t *)http, (msg_header_t *)h);
00225 }
00226 
00228 su_inline
00229 char const *http_header_name(http_header_t const *h, int compact)
00230 {
00231   if (compact && h->sh_class->hc_short[0])
00232     return h->sh_class->hc_short;
00233   else
00234     return h->sh_class->hc_name;
00235 }
00236 
00238 su_inline
00239 void *http_header_data(http_header_t *h)
00240 {
00241   return h && h != HTTP_NONE ? h->sh_class->hc_size + (char *)h : NULL;
00242 }
00243 
00244 su_inline 
00245 http_content_length_t *http_content_length_create(su_home_t *home, uint32_t n)
00246 {
00247   return msg_content_length_create(home, n);
00248 }
00249 
00250 su_inline 
00251 http_payload_t *http_payload_create(su_home_t *home, void const *data, int len)
00252 {
00253   return msg_payload_create(home, data, len);
00254 }
00255 
00256 su_inline 
00257 http_separator_t *http_separator_create(su_home_t *home)
00258 {
00259   return msg_separator_create(home);
00260 }
00261 #endif
00262 
00263 #ifndef HTTP_PROTOS_H
00264 #include <sofia-sip/http_protos.h>
00265 #endif
00266 
00267 SOFIA_END_DECLS
00268 
00269 #endif /* !defined(HTTP_HEADER_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.