http_parser.c File Reference


Detailed Description

HTTP parser.

Author:
Pekka Pessi <Pekka.Pessi@nokia-email.address.hidden>
Date:
Created: Thu Oct 5 14:01:24 2000 ppessi

#include "config.h"
#include <sofia-sip/su_alloc.h>
#include "sofia-sip/http_parser.h"
#include <sofia-sip/msg_parser.h>
#include <sofia-sip/http_header.h>
#include <sofia-sip/http_status.h>
#include <sofia-sip/msg_mclass.h>
#include <sofia-sip/su_tagarg.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <limits.h>
#include <stdarg.h>

Include dependency graph for http_parser.c:


Defines

#define CRLF_TEST(s)
 Calculate length of line ending (0, 1 or 2).

Functions

msg_mclass_t const * http_default_mclass (void)
 HTTP parser description.
issize_t http_extract_body (msg_t *msg, http_t *http, char b[], isize_t bsiz, int eos)
 Extract HTTP message body.
int http_version_d (char **ss, char const **ver)
 Parse HTTP version.
isize_t http_version_xtra (char const *version)
 Calculate extra space required by version string.
void http_version_dup (char **pp, char const **dd, char const *s)
 Duplicate a transport string.
char const * http_method_name (http_method_t method, char const *name)
 Return string corresponding to the method.
http_method_t http_method_d (char **ss, char const **nname)
 Parse a HTTP method name.
http_method_t http_method_code (char const *name)
 Return enum corresponding to the method name.
issize_t http_query_parse (char *query,...)
 Parse query part in HTTP URL.

Variables

char const http_version_1_1 []
 HTTP 1.1 version.
char const http_version_1_0 []
 HTTP 1.0.
char const http_version_0_9 []
 HTTP 0.9.

Function Documentation

msg_mclass_t const* http_default_mclass ( void   ) 

HTTP parser description.

issize_t http_extract_body ( msg_t msg,
http_t http,
char  b[],
isize_t  bsiz,
int  eos 
)

Extract HTTP message body.

Return values:
-1 error
0 cannot proceed
other number of bytes extracted

http_method_t http_method_d ( char **  ss,
char const **  nname 
)

Parse a HTTP method name.

The function http_method_d() parses a HTTP method, and returns a code corresponding to the method. It stores the address of the first non-LWS character after method name in *ss.

Parameters:
ss pointer to pointer to string to be parsed
nname pointer to value-result parameter formethod name
Note:
If there is no whitespace after method name, the value in *nname may not be NUL-terminated. The calling function must NUL terminate the value by setting the **ss to NUL after first examining its value.
Returns:
The function http_method_d returns the method code if method was identified, 0 (http_method_unknown) if method is not known, or -1 (http_method_invalid) if an error occurred.
If the value-result argument nname is not NULL, http_method_d() stores a pointer to the method name to it.

char const* http_method_name ( http_method_t  method,
char const *  name 
)

Return string corresponding to the method.

issize_t http_query_parse ( char *  query,
  ... 
)

Parse query part in HTTP URL.

The function http_query_parse() searches for the given keys in HTTP query. For each key, a query element (in the form name=value) is searched from the query string. If a query element has a beginning matching with the key, a copy of the rest of the element is returned in corresponding return_value argument.

Note:
The query string will be modified.
Returns:
The function http_query_parse() returns number keys that matched within the query string.

int http_version_d ( char **  ss,
char const **  ver 
)

Parse HTTP version.

The function http_version_d() parses a HTTP method.

Return values:
0 when successful,
-1 upon an error.


Variable Documentation

char const http_version_0_9[]

HTTP 0.9.

char const http_version_1_0[]

HTTP 1.0.

char const http_version_1_1[]

HTTP 1.1 version.


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