--- parser3/src/main/pa_http.C 2010/10/28 22:40:25 1.49 +++ parser3/src/main/pa_http.C 2012/03/16 09:24:13 1.53 @@ -1,12 +1,10 @@ /** @file Parser: http support functions. - Copyright(c) 2001-2009 ArtLebedev Group (http://www.artlebedev.com) + Copyright (c) 2001-2012 Art. Lebedev Studio (http://www.artlebedev.com) Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_HTTP_C="$Date: 2010/10/28 22:40:25 $"; - #include "pa_http.h" #include "pa_common.h" #include "pa_charsets.h" @@ -15,6 +13,8 @@ static const char * const IDENT_HTTP_C=" #include "pa_vfile.h" #include "pa_random.h" +volatile const char * IDENT_PA_HTTP_C="$Id: pa_http.C,v 1.53 2012/03/16 09:24:13 moko Exp $" IDENT_PA_HTTP_H; + // defines #define HTTP_METHOD_NAME "method" @@ -295,6 +295,19 @@ struct Http_pass_header_info { bool* content_type_url_encoded; }; #endif + +char *pa_http_safe_header_name(const char *name) { + char *result=pa_strdup(name); + char *n=result; + if(!pa_isalpha((unsigned char)*n)) + *n++ = '_'; + for(; *n; ++n) { + if (!pa_isalnum((unsigned char)*n) && *n != '-' && *n != '_') + *n = '_'; + } + return result; +} + static void http_pass_header(HashStringValue::key_type aname, HashStringValue::value_type avalue, Http_pass_header_info *info) { @@ -304,8 +317,8 @@ static void http_pass_header(HashStringV if(strcasecmp(name_cstr, HTTP_CONTENT_LENGTH)==0) return; - String name=String(capitalize(name_cstr), String::L_URI); - String value=attributed_meaning_to_string(*avalue, String::L_URI, true); + String name=String(pa_http_safe_header_name(capitalize(name_cstr)), String::L_AS_IS); + String value=attributed_meaning_to_string(*avalue, String::L_HTTP_HEADER, true); *info->request << name << ": " << value << CRLF;