]> granicus.if.org Git - php/commitdiff
Fixed bug #43069 (SoapClient causes 505 HTTP Version not supported error message)
authorDmitry Stogov <dmitry@php.net>
Mon, 1 Dec 2008 09:50:18 +0000 (09:50 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 1 Dec 2008 09:50:18 +0000 (09:50 +0000)
ext/soap/php_http.c
ext/soap/php_sdl.c
ext/soap/tests/bugs/bug44811.phpt

index e0df57d3c655a910656c8b7d75d33ec496ef207f..397ef25d8c45de3298851abec724156e7915d9b5 100644 (file)
@@ -374,6 +374,16 @@ try_again:
                        client->url = NULL;
                }
                client->url = phpurl;
+
+               if (client->stream_context && 
+                   php_stream_context_get_option(client->stream_context, "http", "protocol_version", &tmp) == SUCCESS &&
+                   Z_TYPE_PP(tmp) == IS_DOUBLE &&
+                   Z_DVAL_PP(tmp) == 1.0) {
+                       http_1_1 = 0;
+               } else {
+                       http_1_1 = 1;
+               }
+               
                smart_str_append_const(&soap_headers, "POST ");
                if (use_proxy && !use_ssl) {
                        smart_str_appends(&soap_headers, phpurl->scheme);
@@ -395,19 +405,24 @@ try_again:
                        smart_str_appendc(&soap_headers, '#');
                        smart_str_appends(&soap_headers, phpurl->fragment);
                }
-               smart_str_append_const(&soap_headers, " HTTP/1.1\r\n"
-                       "Host: ");
+               if (http_1_1) {
+                       smart_str_append_const(&soap_headers, " HTTP/1.1\r\n");
+               } else {
+                       smart_str_append_const(&soap_headers, " HTTP/1.0\r\n");
+               }
+               smart_str_append_const(&soap_headers, "Host: ");
                smart_str_appends(&soap_headers, phpurl->host);
                if (phpurl->port != (use_ssl?443:80)) {
                        smart_str_appendc(&soap_headers, ':');
                        smart_str_append_unsigned(&soap_headers, phpurl->port);
                }
-               smart_str_append_const(&soap_headers, "\r\n"
-                       "Connection: Keep-Alive\r\n");
-/*
-                       "Connection: close\r\n"
-                       "Accept: text/html; text/xml; text/plain\r\n"
-*/
+               if (http_1_1) {
+                       smart_str_append_const(&soap_headers, "\r\n"
+                               "Connection: Keep-Alive\r\n");
+               } else {
+                       smart_str_append_const(&soap_headers, "\r\n"
+                               "Connection: close\r\n");
+               }
                if (client->user_agent) {
                        if (client->user_agent[0] != 0) {
                                smart_str_append_const(&soap_headers, "User-Agent: ");
index eea25c64e1b4c784bd55dfb59823303c7ac67e59..dd944323d899a81a452dd78ab873a5251365cc5e 100644 (file)
@@ -3092,6 +3092,7 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, long cache_wsdl TSRMLS_DC)
        smart_str headers = {0};
        char* key = NULL;
        time_t t = time(0);
+       zval **tmp;
 
        if (strchr(uri,':') != NULL || IS_ABSOLUTE_PATH(uri, uri_len)) {
                uri_len = strlen(uri);
@@ -3155,6 +3156,8 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, long cache_wsdl TSRMLS_DC)
 
                if (client->stream_context) {
                        context = client->stream_context;
+               } else {
+                       context = php_stream_context_alloc();
                }
 
                if (client->proxy_host) {
@@ -3185,6 +3188,18 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, long cache_wsdl TSRMLS_DC)
                }
 
                basic_authentication(this_ptr, &headers TSRMLS_CC);
+
+               /* Use HTTP/1.1 with "Connection: close" by default */
+               if (php_stream_context_get_option(context, "http", "protocol_version", &tmp) == FAILURE) {
+               zval *http_version;
+
+                       MAKE_STD_ZVAL(http_version);
+                       ZVAL_DOUBLE(http_version, 1.1);
+                       php_stream_context_set_option(context, "http", "protocol_version", http_version);
+                       zval_ptr_dtor(&http_version);
+                       smart_str_appendl(&headers, "Connection: close", sizeof("Connection: close")-1);
+               }
+
        }
 
        if (headers.len > 0) {
index 341e5af51210935b39d28216e6659bb3033eb3c4..47b5c9eeaad49b42281e75e671b0e53be5d25471 100644 (file)
@@ -14,7 +14,7 @@ try {
 }
 die('ok');
 ?>
---EXPECT--
-SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://slashdot.org' : Premature end of data in tag html line 3
+--EXPECTF--
+SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://slashdot.org' : %s
 
 ok