]> 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:49:58 +0000 (09:49 +0000)
committerDmitry Stogov <dmitry@php.net>
Mon, 1 Dec 2008 09:49:58 +0000 (09:49 +0000)
NEWS
ext/soap/php_http.c
ext/soap/php_sdl.c
ext/soap/tests/bugs/bug44811.phpt

diff --git a/NEWS b/NEWS
index 9a9a317966fe0732e4899768f7b9801ffa4e71a8..9d928322a8f95f84adfb9624e950befaa6042ffa 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -95,6 +95,8 @@ PHP                                                                        NEWS
   (David C.)
 - Fixed bug #44154 (pdo->errorInfo() always have three elements in the
   returned array). (David C.)
+- Fixed bug #43069 (SoapClient causes 505 HTTP Version not supported error
+  message). (Dmitry)
 - Fixed bug #41534 (SoapClient over HTTPS fails to reestablish connection).
   (Dmitry)
 
index 9bbb06b39b65b04f559bbec719d6d925ffe9900e..23d104b3382fb169fdee276071e1875ab0693539 100644 (file)
@@ -373,6 +373,15 @@ try_again:
                add_property_resource(this_ptr, "httpurl", ret);
                /*zend_list_addref(ret);*/
 
+               if (context && 
+                   php_stream_context_get_option(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);
@@ -394,19 +403,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 (zend_hash_find(Z_OBJPROP_P(this_ptr), "_user_agent", sizeof("_user_agent"), (void **)&tmp) == SUCCESS &&
                    Z_TYPE_PP(tmp) == IS_STRING) {
                        if (Z_STRLEN_PP(tmp) > 0) {
index fcc90aa742ac9ff576281e8b2eed5947fe88d68f..2ed545bd9e555da7c61c65a84276de729a4932e0 100644 (file)
@@ -3152,6 +3152,8 @@ sdlPtr get_sdl(zval *this_ptr, char *uri, long cache_wsdl TSRMLS_DC)
        if (SUCCESS == zend_hash_find(Z_OBJPROP_P(this_ptr),
                        "_stream_context", sizeof("_stream_context"), (void**)&tmp)) {
                context = php_stream_context_from_zval(*tmp, 0);
+       } else {
+               context = php_stream_context_alloc();
        }
 
        if (zend_hash_find(Z_OBJPROP_P(this_ptr), "_proxy_host", sizeof("_proxy_host"), (void **) &proxy_host) == SUCCESS &&
@@ -3189,6 +3191,16 @@ 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) {
                zval *str_headers;
 
index b2e1fc4f6f2af99293aa63c39f3c95432f7686db..8cfc4a76cddc63646d8138c52294923040f7245f 100644 (file)
@@ -13,7 +13,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