|
|
| version 1.62, 2015/04/02 22:04:41 | version 1.65, 2015/04/30 17:37:43 |
|---|---|
| Line 68 static bool set_addr(struct sockaddr_in | Line 68 static bool set_addr(struct sockaddr_in |
| addr->sin_family=AF_INET; | addr->sin_family=AF_INET; |
| addr->sin_port=htons(port); | addr->sin_port=htons(port); |
| if(host) { | if(host) { |
| ulong packed_ip=inet_addr(host); | struct hostent *hostIP=gethostbyname(host); |
| if(packed_ip!=INADDR_NONE) | if(hostIP && hostIP->h_addrtype == AF_INET){ |
| memcpy(&addr->sin_addr, &packed_ip, sizeof(packed_ip)); | memcpy(&addr->sin_addr, hostIP->h_addr, hostIP->h_length); |
| else { | return true; |
| struct hostent *hostIP=gethostbyname(host); | } |
| if(hostIP) | } |
| memcpy(&addr->sin_addr, hostIP->h_addr, hostIP->h_length); | return false; |
| else | |
| return false; | |
| } | |
| } else | |
| addr->sin_addr.s_addr=INADDR_ANY; | |
| return true; | |
| } | } |
| size_t guess_content_length(char* buf) { | size_t guess_content_length(char* buf) { |
| Line 410 static void form_value2string( | Line 404 static void form_value2string( |
| } else | } else |
| throw Exception(PARSER_RUNTIME, | throw Exception(PARSER_RUNTIME, |
| new String(key, String::L_TAINTED), | new String(key, String::L_TAINTED), |
| "is %s, "HTTP_FORM_NAME" option value can be string or table only (file is allowed for $."HTTP_METHOD_NAME"[POST] + $."HTTP_FORM_ENCTYPE_NAME"["HTTP_CONTENT_TYPE_MULTIPART_FORMDATA"])", value->type()); | "is %s, " HTTP_FORM_NAME " option value can be string or table only (file is allowed for $." HTTP_METHOD_NAME "[POST] + $." HTTP_FORM_ENCTYPE_NAME "[" HTTP_CONTENT_TYPE_MULTIPART_FORMDATA "])", value->type()); |
| } | } |
| const char* pa_form2string(HashStringValue& form, Request_charsets& charsets) { | const char* pa_form2string(HashStringValue& form, Request_charsets& charsets) { |
| Line 516 static void form_value2part( | Line 510 static void form_value2part( |
| } else | } else |
| throw Exception(PARSER_RUNTIME, | throw Exception(PARSER_RUNTIME, |
| new String(key, String::L_TAINTED), | new String(key, String::L_TAINTED), |
| "is %s, "HTTP_FORM_NAME" option value can be string, table or file only", value->type()); | "is %s, " HTTP_FORM_NAME " option value can be string, table or file only", value->type()); |
| } | } |
| const char* pa_form2string_multipart(HashStringValue& form, Request& r, const char* boundary, size_t& post_size){ | const char* pa_form2string_multipart(HashStringValue& form, Request& r, const char* boundary, size_t& post_size){ |
| Line 548 static void find_headers_end(char* p, | Line 542 static void find_headers_end(char* p, |
| // Set-Cookie: name=value; Domain=docs.foo.com; Path=/accounts; Expires=Wed, 13-Jan-2021 22:23:01 GMT; Secure; HttpOnly | // Set-Cookie: name=value; Domain=docs.foo.com; Path=/accounts; Expires=Wed, 13-Jan-2021 22:23:01 GMT; Secure; HttpOnly |
| static ArrayString* parse_cookie(Request& r, const String& cookie) { | static ArrayString* parse_cookie(Request& r, const String& cookie) { |
| char *current=strdup(cookie.cstr()); | char *current=pa_strdup(cookie.cstr()); |
| const String* name=0; | const String* name=0; |
| const String* value=&String::Empty; | const String* value=&String::Empty; |
| Line 711 File_read_http_result pa_internal_file_r | Line 705 File_read_http_result pa_internal_file_r |
| if(method_is_get) | if(method_is_get) |
| throw Exception(PARSER_RUNTIME, | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "you can not use $."HTTP_FORM_ENCTYPE_NAME" option with method GET"); | "you can not use $." HTTP_FORM_ENCTYPE_NAME " option with method GET"); |
| multipart=strcasecmp(encode, HTTP_CONTENT_TYPE_MULTIPART_FORMDATA)==0; | multipart=strcasecmp(encode, HTTP_CONTENT_TYPE_MULTIPART_FORMDATA)==0; |
| if(!multipart && strcasecmp(encode, HTTP_CONTENT_TYPE_FORM_URLENCODED)!=0) | if(!multipart && strcasecmp(encode, HTTP_CONTENT_TYPE_FORM_URLENCODED)!=0) |
| throw Exception(PARSER_RUNTIME, | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "$."HTTP_FORM_ENCTYPE_NAME" option value can be "HTTP_CONTENT_TYPE_FORM_URLENCODED" or "HTTP_CONTENT_TYPE_MULTIPART_FORMDATA" only"); | "$." HTTP_FORM_ENCTYPE_NAME " option value can be " HTTP_CONTENT_TYPE_FORM_URLENCODED " or " HTTP_CONTENT_TYPE_MULTIPART_FORMDATA " only"); |
| } | } |
| if(vbody){ | if(vbody){ |
| if(method_is_get) | if(method_is_get) |
| throw Exception(PARSER_RUNTIME, | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "you can not use $."HTTP_BODY_NAME" option with method GET"); | "you can not use $." HTTP_BODY_NAME " option with method GET"); |
| if(form) | if(form) |
| throw Exception(PARSER_RUNTIME, | throw Exception(PARSER_RUNTIME, |
| 0, | 0, |
| "you can not use options $."HTTP_BODY_NAME" and $."HTTP_FORM_NAME" together"); | "you can not use options $." HTTP_BODY_NAME " and $." HTTP_FORM_NAME " together"); |
| } | } |
| //preparing request | //preparing request |
| Line 890 File_read_http_result pa_internal_file_r | Line 884 File_read_http_result pa_internal_file_r |
| // sending request | // sending request |
| int status_code=http_request(response, response_size, | int status_code=http_request(response, response_size, |
| host, port, request, request_size, | pa_idna_encode(host, r.charsets.source()), port, request, request_size, |
| timeout_secs, fail_on_status_ne_200); | timeout_secs, fail_on_status_ne_200); |
| // processing results | // processing results |