/Users/maurits/Documents/studie/afstuderen/biosphere/common/http_common.c File Reference

#include "http_common.h"
#include "xml.h"
#include <biosphere.h>
#include <apr_strings.h>
#include <apr_lib.h>
#include <apr_network_io.h>
#include <stdlib.h>

Include dependency graph for http_common.c:

Go to the source code of this file.

Functions

bs_bool received_full_headers (const char *headerbuf)
static bs_status extract_http_header_info (char *header, http_header_info *hinfo, apr_pool_t *mp)
bs_status parse_http_headers (const char *headerbuf, apr_size_t headerlen, http_header_info **info, apr_pool_t *mp)
static bs_status receive_response (apr_socket_t *sock, char **response_data, bs_uint64 *length, apr_pool_t *mp)
bs_status connect_and_post (const bs_service_request *request, bs_service_response **response, const char *addr, bs_uint16 port, apr_pool_t *mp)
bs_status connect_and_get (bs_definition **result, const char *addr, bs_uint16 port, apr_pool_t *mp)


Function Documentation

bs_status connect_and_get ( bs_definition **  result,
const char *  addr,
bs_uint16  port,
apr_pool_t *  mp 
)

Connect to a Bio-SPHERE daemon a make a HTTP GET request, in order to retrieve the bs_definitions.

Parameters:
result Result pointer for the definitions
addr The address (IP or hostname) to connect to
port TCP/IP port on which the daemon is listening
mp Memory pool to allocate from
Returns:
Status code.

Definition at line 265 of file http_common.c.

References BIOSPHERE_VERSION_STRING, BS_ERROR, BS_OK, len(), receive_response(), runtestsuite::rv, SERVICE_DEF_FROM_XML, and xlate_from_xml().

Referenced by add_node(), and get_services_list().

Here is the call graph for this function:

bs_status connect_and_post ( const bs_service_request request,
bs_service_response **  response,
const char *  addr,
bs_uint16  port,
apr_pool_t *  mp 
)

Connect to a Bio-SPHERE daemon and post a request.

Parameters:
request The request to make
response The received response (result pointer)
addr The address (IP or hostname) to connect to
port The port on which the local biosphered is listening
mp The memory pool to allocate from
Returns:
Status code

Definition at line 216 of file http_common.c.

References BIOSPHERE_VERSION_STRING, BS_ERROR, BS_OK, BS_UINT64_FMT, receive_response(), runtestsuite::rv, xlate_from_xml(), and xlate_request_to_xml().

Referenced by handle_service_request_remotely(), and make_service_request().

Here is the call graph for this function:

static bs_status extract_http_header_info ( char *  header,
http_header_info hinfo,
apr_pool_t *  mp 
) [static]

Given a single line containing a http header, extract information from it and put it into the given http_header_info structure.

Parameters:
header The line containing the header information
hinfo The structure to fill with info
mp Memory pool to use
Returns:
Status code.

Definition at line 74 of file http_common.c.

References BS_OK, http_header_info::content_length, http_header_info::content_type, http_header_info::http_code, and http_header_info::user_agent.

Referenced by parse_http_headers().

bs_status parse_http_headers ( const char *  headerbuf,
apr_size_t  headerlen,
http_header_info **  info,
apr_pool_t *  mp 
)

Extract header information from the given buffer and filling a http_header_info structure. Returns status code. Assume that appropriate http headers and an ending are present in the given buffer.

Definition at line 105 of file http_common.c.

References BS_HTTP_ERROR, BS_OK, http_header_info::content_length, http_header_info::content_offset, extract_http_header_info(), and runtestsuite::rv.

Referenced by handle_http_post(), and receive_response().

Here is the call graph for this function:

static bs_status receive_response ( apr_socket_t *  sock,
char **  response_data,
bs_uint64 length,
apr_pool_t *  mp 
) [static]

Receive data from the socket, parse HTTP headers and put the resulting payload in the given buffer. This function will never close the given socket.

Parameters:
sock Socket to use for receiving
response_data Result pointer to the buffer to store the response data
length Length of the allocate response data buffer
mp Memory pool to allocate from
Returns:
Status code

Definition at line 159 of file http_common.c.

References BS_HTTP_ERROR, BS_OK, http_header_info::content_length, http_header_info::content_offset, HTTP_BUFFER_SIZE, HTTP_CORRECT, len(), parse_http_headers(), received_full_headers(), and runtestsuite::rv.

Referenced by connect_and_get(), and connect_and_post().

Here is the call graph for this function:

bs_bool received_full_headers ( const char *  headerbuf  ) 

True iff a double line-ending is encountered in the buffer (

or

).

Parameters:
headerbuf Buffer containing the http headers
headerlen The length of that buffer
Returns:
True iff HTTP headers were encountered in the buffer.

Definition at line 45 of file http_common.c.

References FALSE, and TRUE.

Referenced by receive_response(), and worker_thread_main().


Generated on Tue Jul 17 09:50:55 2007 for Bio-SPHERE by  doxygen 1.5.1