|
|
|
@ -23,7 +23,7 @@ |
|
|
|
#include "ext/standard/base64.h" |
|
|
|
|
|
|
|
static char *get_http_header_value(char *headers, char *type); |
|
|
|
static int get_http_body(php_stream *socketd, char *headers, char **response, int *out_size TSRMLS_DC); |
|
|
|
static int get_http_body(php_stream *socketd, int close, char *headers, char **response, int *out_size TSRMLS_DC); |
|
|
|
static int get_http_headers(php_stream *socketd,char **response, int *out_size TSRMLS_DC); |
|
|
|
|
|
|
|
#define smart_str_append_const(str, const) \ |
|
|
|
@ -204,8 +204,8 @@ int make_http_soap_request(zval *this_ptr, |
|
|
|
char *http_headers, *http_body, *content_type, *http_version, *cookie_itt; |
|
|
|
int http_header_size, http_body_size, http_close; |
|
|
|
char *connection; |
|
|
|
int http_1_1 = 0; |
|
|
|
int http_status = 0; |
|
|
|
int http_1_1; |
|
|
|
int http_status; |
|
|
|
char *content_encoding; |
|
|
|
|
|
|
|
if (this_ptr == NULL || Z_TYPE_P(this_ptr) != IS_OBJECT) { |
|
|
|
@ -512,16 +512,22 @@ try_again: |
|
|
|
} |
|
|
|
|
|
|
|
/* Check to see what HTTP status was sent */ |
|
|
|
http_1_1 = 0; |
|
|
|
http_status = 0; |
|
|
|
http_version = get_http_header_value(http_headers,"HTTP/"); |
|
|
|
if (http_version) { |
|
|
|
char *tmp; |
|
|
|
|
|
|
|
tmp = strstr(http_version," "); |
|
|
|
if (strncmp(http_version,"1.1", 3)) { |
|
|
|
http_1_1 = 1; |
|
|
|
} |
|
|
|
|
|
|
|
tmp = strstr(http_version," "); |
|
|
|
if (tmp != NULL) { |
|
|
|
tmp++; |
|
|
|
http_status = atoi(tmp); |
|
|
|
} |
|
|
|
efree(http_version); |
|
|
|
|
|
|
|
/* Process HTTP status codes */ |
|
|
|
if (http_status >= 200 && http_status < 300) { |
|
|
|
@ -534,14 +540,13 @@ try_again: |
|
|
|
int body_size; |
|
|
|
|
|
|
|
if (new_url != NULL) { |
|
|
|
if (get_http_body(stream, http_headers, &body, &body_size TSRMLS_CC)) { |
|
|
|
if (get_http_body(stream, !http_1_1, http_headers, &body, &body_size TSRMLS_CC)) { |
|
|
|
efree(body); |
|
|
|
} else { |
|
|
|
php_stream_close(stream); |
|
|
|
zend_hash_del(Z_OBJPROP_P(this_ptr), "httpsocket", sizeof("httpsocket")); |
|
|
|
stream = NULL; |
|
|
|
} |
|
|
|
efree(http_version); |
|
|
|
efree(http_headers); |
|
|
|
efree(loc); |
|
|
|
if (new_url->scheme == NULL && new_url->path != NULL) { |
|
|
|
@ -596,11 +601,6 @@ try_again: |
|
|
|
return FALSE; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (strncmp(http_version,"1.1", 3)) { |
|
|
|
http_1_1 = 1; |
|
|
|
} |
|
|
|
efree(http_version); |
|
|
|
} |
|
|
|
|
|
|
|
/* Grab and send back every cookie */ |
|
|
|
@ -685,7 +685,7 @@ try_again: |
|
|
|
efree(cookie); |
|
|
|
} |
|
|
|
|
|
|
|
if (!get_http_body(stream, http_headers, &http_body, &http_body_size TSRMLS_CC)) { |
|
|
|
if (!get_http_body(stream, !http_1_1, http_headers, &http_body, &http_body_size TSRMLS_CC)) { |
|
|
|
if (request != buf) {efree(request);} |
|
|
|
php_stream_close(stream); |
|
|
|
efree(http_headers); |
|
|
|
@ -843,19 +843,21 @@ static char *get_http_header_value(char *headers, char *type) |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
|
|
|
|
static int get_http_body(php_stream *stream, char *headers, char **response, int *out_size TSRMLS_DC) |
|
|
|
static int get_http_body(php_stream *stream, int close, char *headers, char **response, int *out_size TSRMLS_DC) |
|
|
|
{ |
|
|
|
char *header, *http_buf = NULL; |
|
|
|
int header_close = 0, header_chunked = 0, header_length = 0, http_buf_size = 0; |
|
|
|
int header_close = close, header_chunked = 0, header_length = 0, http_buf_size = 0; |
|
|
|
|
|
|
|
header = get_http_header_value(headers, "Connection: "); |
|
|
|
if (header) { |
|
|
|
if(!strcmp(header, "close")) header_close = 1; |
|
|
|
efree(header); |
|
|
|
if (!close) { |
|
|
|
header = get_http_header_value(headers, "Connection: "); |
|
|
|
if (header) { |
|
|
|
if(!strncmp(header, "close", sizeof("close")-1)) header_close = 1; |
|
|
|
efree(header); |
|
|
|
} |
|
|
|
} |
|
|
|
header = get_http_header_value(headers, "Transfer-Encoding: "); |
|
|
|
if (header) { |
|
|
|
if(!strcmp(header, "chunked")) header_chunked = 1; |
|
|
|
if(!strncmp(header, "chunked", sizeof("chunked")-1)) header_chunked = 1; |
|
|
|
efree(header); |
|
|
|
} |
|
|
|
header = get_http_header_value(headers, "Content-Length: "); |
|
|
|
|