diff options
author | Dmitry Stogov <dmitry@php.net> | 2005-01-20 17:29:16 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2005-01-20 17:29:16 +0000 |
commit | a343fc848d503366f34e0d8a898d8e1badcac4d5 (patch) | |
tree | 045c844594ac1e123ec63496ad187f44f6a9c2c0 /ext/soap/php_http.c | |
parent | 93e4213bfe93059e33905a9c600a68f34055f21c (diff) | |
download | php-git-a343fc848d503366f34e0d8a898d8e1badcac4d5.tar.gz |
Support for HTTP error codes
Diffstat (limited to 'ext/soap/php_http.c')
-rw-r--r-- | ext/soap/php_http.c | 58 |
1 files changed, 40 insertions, 18 deletions
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, "<?xml", 5)) { + error = 1; + } + } + + if (error) { + efree(*buffer); + 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); + } + return FALSE; + } + } + return TRUE; } |