From: Dmitry Stogov Date: Thu, 20 Jan 2005 17:28:51 +0000 (+0000) Subject: Support for HTTP error codes X-Git-Tag: php-5.0.4RC1~290 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c1b0b3781f3393ed654ad49c3acee838e80899ce;p=php Support for HTTP error codes --- diff --git a/ext/soap/php_http.c b/ext/soap/php_http.c index 47099736d0..819e254bbf 100644 --- a/ext/soap/php_http.c +++ b/ext/soap/php_http.c @@ -584,24 +584,6 @@ try_again: goto try_again; } } -/* - } else if (http_status == 400) { - add_soap_fault(this_ptr, "HTTP", "Bad Request", NULL, NULL TSRMLS_CC); - } else if (http_status == 401) { - add_soap_fault(this_ptr, "HTTP", "Unauthorized Request", NULL, NULL TSRMLS_CC); - } else if (http_status == 405) { - add_soap_fault(this_ptr, "HTTP", "Method not allowed", NULL, NULL TSRMLS_CC); - } else if (http_status == 415) { - add_soap_fault(this_ptr, "HTTP", "Unsupported Media Type", NULL, NULL TSRMLS_CC); - } else if (http_status >= 400 && http_status < 500) { - add_soap_fault(this_ptr, "HTTP", "Client Error", NULL, NULL TSRMLS_CC); - } else if (http_status == 500) { - add_soap_fault(this_ptr, "HTTP", "Internal Server Error", NULL, NULL TSRMLS_CC); - } else if (http_status >= 500 && http_status < 600) { - add_soap_fault(this_ptr, "HTTP", "Server Error", NULL, NULL TSRMLS_CC); - } else { - add_soap_fault(this_ptr, "HTTP", "Unsupported HTTP status code", NULL, NULL TSRMLS_CC); -*/ } /* Try and get headers again */ @@ -819,6 +801,46 @@ try_again: } efree(http_headers); + + if (http_status >= 400) { + int error = 0; + + if (*buffer_len == 0) { + error = 1; + } else if (*buffer_len > 0) { + char *s = *buffer; + + while (*s != '\0' && *s < ' ') { + s++; + } + if (strncmp(s, "= 400 && http_status < 500) { + add_soap_fault(this_ptr, "HTTP", "Client Error", NULL, NULL TSRMLS_CC); + } else if (http_status == 500) { + add_soap_fault(this_ptr, "HTTP", "Internal Server Error", NULL, NULL TSRMLS_CC); + } else if (http_status >= 500 && http_status < 600) { + add_soap_fault(this_ptr, "HTTP", "Server Error", NULL, NULL TSRMLS_CC); + } else { + add_soap_fault(this_ptr, "HTTP", "Unsupported HTTP status code", NULL, NULL TSRMLS_CC); + } + return FALSE; + } + } + return TRUE; } diff --git a/ext/soap/soap.c b/ext/soap/soap.c index e9a0d1278d..a9a258c37a 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -2142,7 +2142,9 @@ static int do_request(zval *this_ptr, xmlDoc *request, char *location, char *act add_soap_fault(this_ptr, "Client", "SoapSlient::__doRequest() failed", NULL, NULL TSRMLS_CC); ret = FALSE; } else if (Z_TYPE_P(response) != IS_STRING) { - add_soap_fault(this_ptr, "Client", "SoapSlient::__doRequest() returned non string value", NULL, NULL TSRMLS_CC); + if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__soap_fault", sizeof("__soap_fault"), (void **) &fault) == FAILURE) { + add_soap_fault(this_ptr, "Client", "SoapSlient::__doRequest() returned non string value", NULL, NULL TSRMLS_CC); + } ret = FALSE; } else if (zend_hash_find(Z_OBJPROP_P(this_ptr), "trace", sizeof("trace"), (void **) &trace) == SUCCESS && Z_LVAL_PP(trace) > 0) {