00001 /* 00002 * Author: MA Hartman 00003 * Date: apr 10, 2007 00004 * 00005 * Function: 00006 * Common HTTP network routines. 00007 * 00008 * License information: 00009 * 00010 * Copyright (c) 2006 Maurits Hartman 00011 * 00012 * Permission is hereby granted, free of charge, to any person 00013 * obtaining a copy of this software and associated documentation 00014 * files (the "Software"), to deal in the Software without 00015 * restriction, including without limitation the rights to use, 00016 * copy, modify, merge, publish, distribute, sublicense, and/or sell 00017 * copies of the Software, and to permit persons to whom the 00018 * Software is furnished to do so, subject to the following 00019 * conditions: 00020 * 00021 * The above copyright notice and this permission notice shall be 00022 * included in all copies or substantial portions of the Software. 00023 * 00024 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00025 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 00026 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00027 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 00028 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 00029 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 00030 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00031 * OTHER DEALINGS IN THE SOFTWARE. 00032 * 00033 */ 00034 00035 #ifndef HTTP_COMMON_H_ 00036 #define HTTP_COMMON_H_ 00037 00038 #include <biosphere.h> 00039 #include <apr_time.h> 00040 00041 #define HTTP_BUFFER_SIZE 512 00042 00046 typedef struct http_header_info { 00047 bs_uint32 http_code; 00048 apr_time_t date; 00049 char *user_agent; 00050 char *server; 00052 bs_uint64 content_length; 00053 char *content_type; 00054 bs_uint32 content_offset; 00055 } http_header_info; 00056 00061 #define HTTP_CORRECT(info) ((info)->http_code == 200) 00062 00069 bs_bool received_full_headers(const char *headerbuf); 00070 00076 bs_status parse_http_headers(const char *headerbuf, apr_size_t headerlen, 00077 http_header_info **info, apr_pool_t *mp); 00078 00088 bs_status connect_and_post(const bs_service_request *request, 00089 bs_service_response **response, const char *addr, 00090 bs_uint16 port, apr_pool_t *mp); 00091 00101 bs_status connect_and_get(bs_definition **result, const char *addr, 00102 bs_uint16 port, apr_pool_t *mp); 00103 00104 #endif /*HTTP_COMMON_H_*/