00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
00058
00059
00061 #define HTTP_HEADER_INIT(h, http_class, size) \
00062 ((void)memset((h), 0, (size)), \
00063 (void)(((msg_common_t *)(h))->h_class = (http_class)), \
00064 (h))
00065
00066 #define HTTP_METHOD_NAME(method, name) \
00067 ((method) == http_method_unknown ? (name) : http_method_name(method, name))
00068
00069
00070
00071
00072
00073 SOFIAPUBVAR char const http_method_name_get[];
00074 SOFIAPUBVAR char const http_method_name_post[];
00075 SOFIAPUBVAR char const http_method_name_head[];
00076 SOFIAPUBVAR char const http_method_name_options[];
00077 SOFIAPUBVAR char const http_method_name_put[];
00078 SOFIAPUBVAR char const http_method_name_delete[];
00079 SOFIAPUBVAR char const http_method_name_trace[];
00080 SOFIAPUBVAR char const http_method_name_connect[];
00081
00083 SOFIAPUBVAR char const http_version_0_9[];
00084
00086 SOFIAPUBVAR char const http_version_1_0[];
00087
00089 SOFIAPUBVAR char const http_version_1_1[];
00090
00091 #define HTTP_VERSION_CURRENT http_version_1_1
00092
00093
00094
00095
00096
00098 SOFIAPUBFUN msg_mclass_t const *http_default_mclass(void);
00099
00101 SOFIAPUBFUN int http_request_complete(msg_t *msg);
00102
00104 SOFIAPUBFUN int http_message_complete(msg_t *msg, http_t *http);
00105
00107 SOFIAPUBFUN int http_add_dup(msg_t *, http_t *, http_header_t const *);
00108
00110 SOFIAPUBFUN int http_add_make(msg_t *msg, http_t *http,
00111 msg_hclass_t *hc, char const *s);
00112
00114 SOFIAPUBFUN int http_add_format(msg_t *msg, http_t *http, msg_hclass_t *hc,
00115 char const *fmt, ...);
00116
00118 SOFIAPUBFUN int http_add_tl(msg_t *msg, http_t *http,
00119 tag_type_t tag, tag_value_t value, ...);
00120
00122 SOFIAPUBFUN int http_strip_hostport(url_t *url);
00123
00125 SOFIAPUBFUN int http_complete_response(msg_t *msg,
00126 int status, char const *phrase,
00127 http_t const *request);
00128
00130 SOFIAPUBFUN char const *http_method_name(http_method_t method,
00131 char const *name);
00132
00134 SOFIAPUBFUN http_method_t http_method_code(char const *name);
00135
00136 #if !SU_HAVE_INLINE
00137 SOFIAPUBFUN http_t *http_object(msg_t *msg);
00138 SOFIAPUBFUN int http_header_insert(msg_t *msg, http_t *http, http_header_t *h);
00139 SOFIAPUBFUN int http_header_remove(msg_t *msg, http_t *http, http_header_t *h);
00140 SOFIAPUBFUN char const *http_header_name(http_header_t const *h, int compact);
00141 SOFIAPUBFUN void *http_header_data(http_header_t *h);
00142 SOFIAPUBFUN http_content_length_t *http_content_length_create(su_home_t *home,
00143 uint32_t n);
00144 SOFIAPUBFUN http_payload_t *http_payload_create(su_home_t *home,
00145 void const *data, usize_t len);
00146 SOFIAPUBFUN http_separator_t *http_separator_create(su_home_t *home);
00147 #endif
00148
00149 SOFIAPUBFUN http_header_t *http_header_format(su_home_t *home, msg_hclass_t *,
00150 char const *fmt, ...);
00151
00152
00154 SOFIAPUBFUN http_request_t *http_request_create(su_home_t *home,
00155 http_method_t method,
00156 const char *name,
00157 url_string_t const *url,
00158 char const *version);
00159
00161 SOFIAPUBFUN http_status_t *http_status_create(su_home_t *home,
00162 unsigned status,
00163 char const *phrase,
00164 char const *version);
00165
00167 SOFIAPUBFUN http_host_t *http_host_create(su_home_t *home,
00168 char const *host,
00169 char const *port);
00170
00172 SOFIAPUBFUN http_date_t *http_date_create(su_home_t *home, http_time_t t);
00173
00175 SOFIAPUBFUN http_expires_t *http_expires_create(su_home_t *home,
00176 http_time_t delta);
00177
00179 SOFIAPUBFUN int http_url_cmp(url_t const *a, url_t const *b);
00180
00182 SOFIAPUBFUN issize_t http_query_parse(char *query,
00183
00184 ...);
00185
00186
00187
00188
00189
00190 #if SU_HAVE_INLINE
00191
00192 su_inline
00193 http_t *http_object(msg_t *msg)
00194 {
00195 return (http_t *)msg_public(msg, HTTP_PROTOCOL_TAG);
00196 }
00197
00216 su_inline
00217 int http_header_insert(msg_t *msg, http_t *http, http_header_t *h)
00218 {
00219 return msg_header_insert(msg, (msg_pub_t *)http, (msg_header_t *)h);
00220 }
00221
00223 su_inline
00224 int http_header_remove(msg_t *msg, http_t *http, http_header_t *h)
00225 {
00226 return msg_header_remove(msg, (msg_pub_t *)http, (msg_header_t *)h);
00227 }
00228
00230 su_inline
00231 char const *http_header_name(http_header_t const *h, int compact)
00232 {
00233 if (compact && h->sh_class->hc_short[0])
00234 return h->sh_class->hc_short;
00235 else
00236 return h->sh_class->hc_name;
00237 }
00238
00240 su_inline
00241 void *http_header_data(http_header_t *h)
00242 {
00243 return h && h != HTTP_NONE ? h->sh_class->hc_size + (char *)h : NULL;
00244 }
00245
00246 su_inline
00247 http_content_length_t *http_content_length_create(su_home_t *home, uint32_t n)
00248 {
00249 return msg_content_length_create(home, n);
00250 }
00251
00252 su_inline
00253 http_payload_t *http_payload_create(su_home_t *home, void const *data, isize_t len)
00254 {
00255 return msg_payload_create(home, data, len);
00256 }
00257
00258 su_inline
00259 http_separator_t *http_separator_create(su_home_t *home)
00260 {
00261 return msg_separator_create(home);
00262 }
00263 #endif
00264
00265 SOFIA_END_DECLS
00266
00267 #ifndef HTTP_PROTOS_H
00268 #include <sofia-sip/http_protos.h>
00269 #endif
00270
00271 #endif