Hardcoded faultstring in add_soap_fault on HTTP error codes
| From: | Knut Urdalen | Date: | Fri, 17 Feb 2006 10:48:16 +0000 |
| Subject: | Hardcoded faultstring in add_soap_fault on HTTP error codes | ||
| Groups: | php.soap | ||
| Request: | Send a blank email to php-soap+get-2135@lists.php.net to get a copy of this message | ||
Hi,
I see that ext/soap/php_http.c contains hardcoded HTTP messages when creating SoapFault exceptions:
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);
}
This seems like a bad decision since we loose the actual response message. I think it would be better to have both the response code and the response string inside the faultstring on these types of HTTP responses.
There are many situations where you may get the same response code for different response messages.
Best regards,
Knut Urdalen