Loading...
Searching...
No Matches
http_header.h
Go to the documentation of this file.
/*
* This file is part of the Sofia-SIP package
*
* Copyright (C) 2005 Nokia Corporation.
*
* Contact: Pekka Pessi <pekka.pessi@nokia-email.address.hidden>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef HTTP_HEADER_H
#define HTTP_HEADER_H
#ifndef SU_ALLOC_H
#include <sofia-sip/su_alloc.h>
#endif
#ifndef SU_TAG_H
#include <sofia-sip/su_tag.h>
#endif
#ifndef HTTP_H
#include <sofia-sip/http.h>
#endif
#ifndef MSG_HEADER_H
#include <sofia-sip/msg_header.h>
#endif
SOFIA_BEGIN_DECLS
/* ----------------------------------------------------------------------
* 1) Macros
*/
#define HTTP_HEADER_INIT(h, http_class, size) \
((void)memset((h), 0, (size)), \
(void)(((msg_common_t *)(h))->h_class = (http_class)), \
(h))
#define HTTP_METHOD_NAME(method, name) \
((method) == http_method_unknown ? (name) : http_method_name(method, name))
/* ----------------------------------------------------------------------
* 2) Variables
*/
SOFIAPUBVAR char const http_method_name_get[];
SOFIAPUBVAR char const http_method_name_post[];
SOFIAPUBVAR char const http_method_name_head[];
SOFIAPUBVAR char const http_method_name_options[];
SOFIAPUBVAR char const http_method_name_put[];
SOFIAPUBVAR char const http_method_name_delete[];
SOFIAPUBVAR char const http_method_name_trace[];
SOFIAPUBVAR char const http_method_name_connect[];
SOFIAPUBVAR char const http_version_0_9[];
SOFIAPUBVAR char const http_version_1_0[];
SOFIAPUBVAR char const http_version_1_1[];
#define HTTP_VERSION_CURRENT http_version_1_1
/* ----------------------------------------------------------------------
* 3) Prototypes
*/
SOFIAPUBFUN msg_mclass_t const *http_default_mclass(void);
SOFIAPUBFUN int http_request_complete(msg_t *msg);
SOFIAPUBFUN int http_message_complete(msg_t *msg, http_t *http);
SOFIAPUBFUN int http_add_dup(msg_t *, http_t *, http_header_t const *);
SOFIAPUBFUN int http_add_make(msg_t *msg, http_t *http,
msg_hclass_t *hc, char const *s);
SOFIAPUBFUN int http_add_format(msg_t *msg, http_t *http, msg_hclass_t *hc,
char const *fmt, ...);
SOFIAPUBFUN int http_add_tl(msg_t *msg, http_t *http,
tag_type_t tag, tag_value_t value, ...);
SOFIAPUBFUN int http_strip_hostport(url_t *url);
SOFIAPUBFUN int http_complete_response(msg_t *msg,
int status, char const *phrase,
http_t const *request);
SOFIAPUBFUN char const *http_method_name(http_method_t method,
char const *name);
SOFIAPUBFUN http_method_t http_method_code(char const *name);
#if !SU_HAVE_INLINE
SOFIAPUBFUN http_t *http_object(msg_t *msg);
SOFIAPUBFUN int http_header_insert(msg_t *msg, http_t *http, http_header_t *h);
SOFIAPUBFUN int http_header_remove(msg_t *msg, http_t *http, http_header_t *h);
SOFIAPUBFUN char const *http_header_name(http_header_t const *h, int compact);
SOFIAPUBFUN void *http_header_data(http_header_t *h);
SOFIAPUBFUN http_content_length_t *http_content_length_create(su_home_t *home,
uint32_t n);
SOFIAPUBFUN http_payload_t *http_payload_create(su_home_t *home,
void const *data, usize_t len);
SOFIAPUBFUN http_separator_t *http_separator_create(su_home_t *home);
#endif
SOFIAPUBFUN http_header_t *http_header_format(su_home_t *home, msg_hclass_t *,
char const *fmt, ...);
SOFIAPUBFUN 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);
SOFIAPUBFUN http_status_t *http_status_create(su_home_t *home,
unsigned status,
char const *phrase,
char const *version);
SOFIAPUBFUN http_host_t *http_host_create(su_home_t *home,
char const *host,
char const *port);
SOFIAPUBFUN http_date_t *http_date_create(su_home_t *home, http_time_t t);
SOFIAPUBFUN http_expires_t *http_expires_create(su_home_t *home,
http_time_t delta);
SOFIAPUBFUN int http_url_cmp(url_t const *a, url_t const *b);
SOFIAPUBFUN issize_t http_query_parse(char *query,
/* char const *key, char **return_value, */
...);
/* ----------------------------------------------------------------------
* 4) Inlined functions
*/
#if SU_HAVE_INLINE
su_inline
http_t *http_object(msg_t *msg)
{
return (http_t *)msg_public(msg, HTTP_PROTOCOL_TAG);
}
su_inline
int http_header_insert(msg_t *msg, http_t *http, http_header_t *h)
{
return msg_header_insert(msg, (msg_pub_t *)http, (msg_header_t *)h);
}
su_inline
int http_header_remove(msg_t *msg, http_t *http, http_header_t *h)
{
return msg_header_remove(msg, (msg_pub_t *)http, (msg_header_t *)h);
}
su_inline
char const *http_header_name(http_header_t const *h, int compact)
{
if (compact && h->sh_class->hc_short[0])
return h->sh_class->hc_short;
else
return h->sh_class->hc_name;
}
su_inline
void *http_header_data(http_header_t *h)
{
return h && h != HTTP_NONE ? h->sh_class->hc_size + (char *)h : NULL;
}
su_inline
http_content_length_t *http_content_length_create(su_home_t *home, uint32_t n)
{
return msg_content_length_create(home, n);
}
su_inline
http_payload_t *http_payload_create(su_home_t *home, void const *data, isize_t len)
{
return msg_payload_create(home, data, len);
}
su_inline
http_separator_t *http_separator_create(su_home_t *home)
{
return msg_separator_create(home);
}
#endif
SOFIA_END_DECLS
#ifndef HTTP_PROTOS_H
#include <sofia-sip/http_protos.h>
#endif
#endif /* !defined(HTTP_HEADER_H) */
http_date_create
http_date_t * http_date_create(su_home_t *home, http_time_t t)
Create an Date header object.
Definition http_basic.c:584
http_date_t
struct http_date_s http_date_t
@HTTP_HEADER http_content_type Content-Type header.
Definition http.h:123
http_expires_t
http_date_t http_expires_t
@HTTP_HEADER http_expires Expires header.
Definition http.h:126
msg_content_length_create
msg_content_length_t * msg_content_length_create(su_home_t *, uint32_t n)
http.h
HTTP message, methods, headers.
HTTP_PROTOCOL_TAG
#define HTTP_PROTOCOL_TAG
HTTP protocol identifier.
Definition http.h:61
http_method_t
http_method_t
IDs for well-known HTTP methods.
Definition http.h:69
http_payload_t
msg_payload_t http_payload_t
Entity-body.
Definition http.h:167
http_separator_t
msg_separator_t http_separator_t
Separator line between headers and message contents.
Definition http.h:165
http_time_t
unsigned long http_time_t
Time in seconds since 01-Jan-1900.
Definition http.h:169
http_t
struct http_s http_t
HTTP message object.
Definition http.h:98
http_header_t
union http_header_u http_header_t
Any HTTP header - union of all possible HTTP headers.
Definition http.h:101
http_method_code
http_method_t http_method_code(char const *name)
Return enum corresponding to the method name.
Definition http_parser.c:500
http_status_create
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
http_version_0_9
char const http_version_0_9[]
HTTP 0.9.
Definition http_parser.c:62
http_version_1_1
char const http_version_1_1[]
HTTP 1.1 version.
Definition http_parser.c:58
http_add_format
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_create
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
http_method_name
char const * http_method_name(http_method_t method, char const *name)
Return string corresponding to the method.
Definition http_parser.c:416
http_header_remove
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
http_add_dup
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
http_version_1_0
char const http_version_1_0[]
HTTP 1.0.
Definition http_parser.c:60
http_header_insert
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
http_complete_response
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
http_message_complete
int http_message_complete(msg_t *msg, http_t *http)
Complete a HTTP message.
Definition http_header.c:120
http_url_cmp
int http_url_cmp(url_t const *a, url_t const *b)
Compare two HTTP URLs.
Definition http_header.c:281
http_strip_hostport
int http_strip_hostport(url_t *url)
Remove schema, host, and port from URL.
Definition http_header.c:99
http_add_make
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
http_add_tl
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
http_header_data
void * http_header_data(http_header_t *h)
Return data after header structure.
Definition http_header.h:241
http_object
http_t * http_object(msg_t *msg)
Get HTTP structure from msg.
Definition http_header.h:193
http_default_mclass
msg_mclass_t const * http_default_mclass(void)
HTTP parser description.
Definition http_parser.c:64
http_expires_create
http_expires_t * http_expires_create(su_home_t *home, http_time_t delta)
Create an Expires header object.
http_request_complete
int http_request_complete(msg_t *msg)
Complete a HTTP request.
Definition http_header.c:62
http_host_create
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
http_header_name
char const * http_header_name(http_header_t const *h, int compact)
Return name of the header.
Definition http_header.h:231
http_query_parse
issize_t http_query_parse(char *query,...)
Parse query part in HTTP URL.
Definition http_parser.c:520
http_protos.h
Macros for each HTTP header.
msg_public
msg_pub_t * msg_public(msg_t const *msg, void *tag)
msg_header.h
msg_payload_create
msg_payload_t * msg_payload_create(su_home_t *home, void const *data, usize_t len))
msg_header_insert
int msg_header_insert(msg_t *msg, msg_pub_t *mo, msg_header_t *h)
msg_header_remove
int msg_header_remove(msg_t *msg, msg_pub_t *mo, msg_header_t *h)
msg_hclass_t
struct msg_hclass_s const msg_hclass_t
msg_header_t
MSG_HDR_T msg_header_t
msg_t
struct msg_s msg_t
msg_pub_t
MSG_PUB_T msg_pub_t
msg_mclass_t
struct msg_mclass_s msg_mclass_t
url_t
su_alloc.h
su_home_t
SU_HOME_T su_home_t
SOFIAPUBFUN
#define SOFIAPUBFUN
SOFIAPUBVAR
#define SOFIAPUBVAR
su_inline
#define su_inline
su_tag.h
tag_value_t
intptr_t tag_value_t
tag_type_t
struct tag_type_s const * tag_type_t
uint32_t
SU_U32_T uint32_t
url_string_t

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