|
|
| version 1.9, 2008/02/15 11:51:22 | version 1.10, 2008/02/20 08:55:15 |
|---|---|
| Line 19 static const char * const IDENT_HTTP_C=" | Line 19 static const char * const IDENT_HTTP_C=" |
| #define HTTP_BODY_NAME "body" | #define HTTP_BODY_NAME "body" |
| #define HTTP_TIMEOUT_NAME "timeout" | #define HTTP_TIMEOUT_NAME "timeout" |
| #define HTTP_HEADERS_NAME "headers" | #define HTTP_HEADERS_NAME "headers" |
| #define HTTP_COOKIES_NAME "cookies" | |
| #define HTTP_ANY_STATUS_NAME "any-status" | #define HTTP_ANY_STATUS_NAME "any-status" |
| // #define HTTP_CHARSET_NAME "charset" | // #define HTTP_CHARSET_NAME "charset" |
| #define HTTP_TABLES_NAME "tables" | #define HTTP_TABLES_NAME "tables" |
| Line 289 static void http_pass_header(HashStringV | Line 290 static void http_pass_header(HashStringV |
| HashStringValue::value_type value, | HashStringValue::value_type value, |
| Http_pass_header_info *info) { | Http_pass_header_info *info) { |
| String aname=String(name, String::L_HTTP_HEADER); | String aname=String(name, String::L_URI); |
| *info->request <<aname<<": " | *info->request <<aname<<": " |
| << attributed_meaning_to_string(*value, String::L_HTTP_HEADER, false) | << attributed_meaning_to_string(*value, String::L_URI, false) |
| << CRLF; | << CRLF; |
| if(aname.change_case(info->charsets->source(), String::CC_UPPER)=="USER-AGENT") | if(aname.change_case(info->charsets->source(), String::CC_UPPER)=="USER-AGENT") |
| info->user_agent_specified=true; | info->user_agent_specified=true; |
| } | } |
| static void http_pass_cookie(HashStringValue::key_type name, | |
| HashStringValue::value_type value, | |
| Http_pass_header_info *info) { | |
| *info->request << String(name, String::L_HTTP_HEADER) << "=" | |
| << attributed_meaning_to_string(*value, String::L_HTTP_HEADER, false) | |
| << "; "; | |
| } | |
| static Charset* detect_charset(Charset& source_charset, const String& content_type_value) { | static Charset* detect_charset(Charset& source_charset, const String& content_type_value) { |
| const String::Body CONTENT_TYPE_VALUE= | const String::Body CONTENT_TYPE_VALUE= |
| Line 416 File_read_http_result pa_internal_file_r | Line 426 File_read_http_result pa_internal_file_r |
| char host[MAX_STRING]; | char host[MAX_STRING]; |
| const char* uri; | const char* uri; |
| short port; | short port; |
| const char* method="GET"; bool method_is_get; | const char* method="GET"; |
| HashStringValue* form=0; | HashStringValue* form=0; |
| const char* body_cstr=0; | const char* body_cstr=0; |
| int timeout_secs=2; | int timeout_secs=2; |
| bool fail_on_status_ne_200=true; | bool fail_on_status_ne_200=true; |
| Value* vheaders=0; | Value* vheaders=0; |
| Value* vcookies=0; | |
| Charset *asked_remote_charset=0; | Charset *asked_remote_charset=0; |
| const char* user_cstr=0; | const char* user_cstr=0; |
| const char* password_cstr=0; | const char* password_cstr=0; |
| Line 448 File_read_http_result pa_internal_file_r | Line 459 File_read_http_result pa_internal_file_r |
| if((vheaders=options->get(HTTP_HEADERS_NAME))) { | if((vheaders=options->get(HTTP_HEADERS_NAME))) { |
| valid_options++; | valid_options++; |
| } | } |
| if((vcookies=options->get(HTTP_COOKIES_NAME))) { | |
| valid_options++; | |
| } | |
| if(Value* vany_status=options->get(HTTP_ANY_STATUS_NAME)) { | if(Value* vany_status=options->get(HTTP_ANY_STATUS_NAME)) { |
| valid_options++; | valid_options++; |
| fail_on_status_ne_200=!vany_status->as_bool(); | fail_on_status_ne_200=!vany_status->as_bool(); |
| } | } |
| if(Value* vcharset_name=options->get(PA_CHARSET_NAME)) { | if(Value* vcharset_name=options->get(PA_CHARSET_NAME)) { |
| // valid_options++; | |
| asked_remote_charset=&::charsets.get(vcharset_name->as_string(). | asked_remote_charset=&::charsets.get(vcharset_name->as_string(). |
| change_case(charsets.source(), String::CC_UPPER)); | change_case(charsets.source(), String::CC_UPPER)); |
| } | } |
| Line 474 File_read_http_result pa_internal_file_r | Line 487 File_read_http_result pa_internal_file_r |
| if(!asked_remote_charset) // defaulting to $request:charset | if(!asked_remote_charset) // defaulting to $request:charset |
| asked_remote_charset=&charsets.source(); | asked_remote_charset=&charsets.source(); |
| method_is_get=strcmp(method, "GET")==0; | bool method_is_get=strcmp(method, "GET")==0; |
| if(method_is_get && body_cstr) | if(method_is_get && body_cstr) |
| throw Exception(PARSER_RUNTIME, | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| Line 540 File_read_http_result pa_internal_file_r | Line 553 File_read_http_result pa_internal_file_r |
| if(!user_agent_specified) // defaulting | if(!user_agent_specified) // defaulting |
| head << "user-agent: " DEFAULT_USER_AGENT CRLF; | head << "user-agent: " DEFAULT_USER_AGENT CRLF; |
| if(vcookies && !vcookies->is_string()){ | |
| if(HashStringValue* cookies=vcookies->get_hash()) { | |
| head << "cookie: "; | |
| Http_pass_header_info info={&charsets, &head, false}; | |
| cookies->for_each<Http_pass_header_info*>(http_pass_cookie, &info); | |
| head << CRLF; | |
| } else | |
| throw Exception(PARSER_RUNTIME, | |
| &connect_string, | |
| "cookies param must be hash"); | |
| } | |
| if(body_cstr) { | if(body_cstr) { |
| head << "content-length: " << format(strlen(body_cstr), "%u") << CRLF; | head << "content-length: " << format(strlen(body_cstr), "%u") << CRLF; |
| } | } |