#include "http.h"
#include "settings.h"
#include "service.h"
#include <copy.h>
#include <xml.h>
#include <apr_strings.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
Include dependency graph for http.c:
Go to the source code of this file.
Functions | |
static char * | get_remote_endpoint (apr_socket_t *sock, apr_pool_t *mp) |
bs_status | handle_http_get (apr_socket_t *sock, apr_pool_t *mp) |
static bs_status | get_remaining_content (apr_socket_t *sock, char **result, const char *initial, unsigned size, bs_uint64 remaining, apr_pool_t *mp) |
static bs_status | check_for_http_errors (apr_socket_t *sock, http_header_info *info, apr_pool_t *mp) |
bs_status | handle_http_post (apr_socket_t *sock, const char *headerbuf, apr_size_t headerlen, apr_pool_t *mp) |
bs_status | send_http_error (apr_socket_t *sock, const char *errstring, apr_pool_t *mp) |
static bs_status check_for_http_errors | ( | apr_socket_t * | sock, | |
http_header_info * | info, | |||
apr_pool_t * | mp | |||
) | [static] |
Check to see if the right information was provided along with the HTTP headers. Use the http_header_info struct for this. Send an appropriate error message back through the socket.
Definition at line 162 of file http.c.
References BIOSPHERED_MAX_CONTENT_LENGTH, BS_ERROR, BS_OK, http_header_info::content_length, http_header_info::content_type, and send_http_error().
Referenced by handle_http_post().
Here is the call graph for this function:
static bs_status get_remaining_content | ( | apr_socket_t * | sock, | |
char ** | result, | |||
const char * | initial, | |||
unsigned | size, | |||
bs_uint64 | remaining, | |||
apr_pool_t * | mp | |||
) | [static] |
Try to receive the remaining content from the given socket. Put the initial result and the rest of the received data in the result buffer. Return status code about the whole process. If the desired content size is just to big (see setting.h) return an eror through the socket.
Definition at line 119 of file http.c.
References BS_ERROR, BS_OK, HTTP_BUFFER_SIZE, and runtestsuite::rv.
Referenced by handle_http_post().
static char* get_remote_endpoint | ( | apr_socket_t * | sock, | |
apr_pool_t * | mp | |||
) | [static] |
bs_status handle_http_get | ( | apr_socket_t * | sock, | |
apr_pool_t * | mp | |||
) |
Handle a HTTP GET request by simply outputting an HTML status page. This page is the banner.html file included in the daemon directory by default.
sock | Socket to use | |
mp | Memory pool to allocate from |
Definition at line 62 of file http.c.
References BIOSPHERE_VERSION_STRING, BS_ERROR, BS_OK, BS_UINT64_FMT, get_remote_endpoint(), get_services(), len(), runtestsuite::rv, send_http_error(), and xlate_definition_to_xml().
Referenced by worker_thread_main().
Here is the call graph for this function:
bs_status handle_http_post | ( | apr_socket_t * | sock, | |
const char * | headerbuf, | |||
apr_size_t | headerlen, | |||
apr_pool_t * | mp | |||
) |
Handle a HTTP POST request by assuming it contains an XML request for a service. First the HTTP headers are interpreted, then the xml payload is translated into an internal data structure (
sock | Socket to use | |
headerbuf | Buffer containing HTTP headers and (part) of the xml data | |
headerlen | Length of the buffer | |
mp | Memory pool to allocate from |
Definition at line 183 of file http.c.
References BIOSPHERE_VERSION_STRING, BS_ERROR, BS_OK, BS_UINT64_FMT, check_for_http_errors(), http_header_info::content_length, http_header_info::content_offset, delete_response(), get_remaining_content(), get_remote_endpoint(), handle_service_request(), len(), parse_http_headers(), runtestsuite::rv, send_http_error(), SERVICE_REQUEST_FROM_XML, xlate_from_xml(), and xlate_response_to_xml().
Referenced by worker_thread_main().
Here is the call graph for this function:
bs_status send_http_error | ( | apr_socket_t * | sock, | |
const char * | errstring, | |||
apr_pool_t * | mp | |||
) |
Send an HTTP message through the socket indicating an error.
sock | Socket to use (not closed by this function) | |
errstring | The error string to send (ie. HTTP 404 Not Found) | |
mp | Memory pool to allocate from |
Definition at line 274 of file http.c.
References BIOSPHERE_VERSION_STRING, BS_ERROR, BS_OK, len(), and runtestsuite::rv.
Referenced by check_for_http_errors(), handle_http_get(), handle_http_post(), and worker_thread_main().
Here is the call graph for this function: