--- parser3/src/main/pa_http.C 2009/08/30 05:28:49 1.37 +++ parser3/src/main/pa_http.C 2009/10/15 01:07:54 1.44 @@ -5,7 +5,7 @@ Author: Alexandr Petrosian (http://paf.design.ru) */ -static const char * const IDENT_HTTP_C="$Date: 2009/08/30 05:28:49 $"; +static const char * const IDENT_HTTP_C="$Date: 2009/10/15 01:07:54 $"; #include "pa_http.h" #include "pa_common.h" @@ -322,15 +322,19 @@ static void http_pass_header(HashStringV HashStringValue::value_type avalue, Http_pass_header_info *info) { - String name=String(aname, String::L_URI); - String value=attributed_meaning_to_string(*avalue, String::L_URI, false); + const char* name_cstr=aname.cstr(); + + 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); *info->request << name << ": " << value << CRLF; - const String::Body NAME=name.change_case(info->charsets->source(), String::CC_UPPER); - if(NAME==HTTP_USER_AGENT_UPPER) + if(strcasecmp(name_cstr, HTTP_USER_AGENT)==0) *info->user_agent_specified=true; - if(NAME==HTTP_CONTENT_TYPE_UPPER){ + if(strcasecmp(name_cstr, HTTP_CONTENT_TYPE)==0){ *info->content_type_specified=true; *info->content_type_url_encoded=StrStartFromNC(value.cstr(), HTTP_CONTENT_TYPE_FORM_URLENCODED); } @@ -401,7 +405,7 @@ static void form_value2string( const char* pa_form2string(HashStringValue& form, Request_charsets& charsets) { String string; form.for_each(form_value2string, &string); - return string.transcode_and_untaint_cstr(String::L_URI, &charsets); + return string.untaint_and_transcode_cstr(String::L_URI, &charsets); } struct FormPart { @@ -413,13 +417,13 @@ struct FormPart { static void form_part_boundary_header(FormPart& part, String::Body name, const char* file_name=0){ part.string << "--" << part.boundary - << CRLF CONTENT_DISPOSITION ": form-data; name=\"" + << CRLF CONTENT_DISPOSITION_CAPITALIZED ": form-data; name=\"" << Charset::transcode(name, part.r->charsets.source(), part.r->charsets.client()) << "\""; if(file_name){ if(strcmp(file_name, NONAME_DAT)!=0) part.string << "; filename=\"" << file_name << "\""; - part.string << CRLF HTTP_CONTENT_TYPE ": " << part.r->mime_type_of(file_name); + part.string << CRLF HTTP_CONTENT_TYPE_CAPITALIZED ": " << part.r->mime_type_of(file_name); } part.string << CRLF CRLF; } @@ -575,7 +579,7 @@ File_read_http_result pa_internal_file_r if(valid_options!=options->count()) throw Exception(PARSER_RUNTIME, 0, - "invalid option passed"); + INVALID_OPTION_PASSED); } if(!asked_remote_charset) // defaulting to $request:charset asked_remote_charset=&(r.charsets).source(); @@ -614,7 +618,7 @@ File_read_http_result pa_internal_file_r // influence URLencoding of tainted pieces to String::L_URI lang Temp_client_charset temp(r.charsets, *asked_remote_charset); - const char* connect_string_cstr=connect_string.transcode_and_untaint_cstr(String::L_URI, &(r.charsets)); + const char* connect_string_cstr=connect_string.untaint_and_transcode_cstr(String::L_URI, &(r.charsets)); const char* current=connect_string_cstr; if(strncmp(current, "http://", 7)!=0) @@ -673,7 +677,7 @@ File_read_http_result pa_internal_file_r size_t post_size=0; if(form && !method_is_get) { - head << HTTP_CONTENT_TYPE ": " << (multipart ? HTTP_CONTENT_TYPE_MULTIPART_FORMDATA : HTTP_CONTENT_TYPE_FORM_URLENCODED); + head << "Content-Type: " << (multipart ? HTTP_CONTENT_TYPE_MULTIPART_FORMDATA : HTTP_CONTENT_TYPE_FORM_URLENCODED); if(!omit_post_charset) head << "; charset=" << asked_remote_charset->NAME_CSTR(); @@ -687,9 +691,10 @@ File_read_http_result pa_internal_file_r } head << CRLF; } else if(vbody) { + // $.body was specified if(content_type_url_encoded){ // transcode + url-encode - body_cstr=vbody->as_string().transcode_and_untaint_cstr(String::L_URI, &(r.charsets)); + body_cstr=vbody->as_string().untaint_and_transcode_cstr(String::L_URI, &(r.charsets)); } else { // content-type != application/x-www-form-urlencoded -> transcode only, don't url-encode! body_cstr=Charset::transcode( @@ -703,12 +708,12 @@ File_read_http_result pa_internal_file_r // http://www.ietf.org/rfc/rfc2617.txt if(const String* authorization_field_value=basic_authorization_field(user_cstr, password_cstr)) - head<<"Authorization: "<<*authorization_field_value<