cvs: php-src /ext/soap php_http.c
| From: | Ilia Alshanetsky | Date: | Tue, 27 Jun 2006 23:33:19 +0000 |
| Subject: | cvs: php-src /ext/soap php_http.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-38961@lists.php.net to get a copy of this message | ||
iliaa Tue Jun 27 23:33:19 2006 UTC
Modified files:
/php-src/ext/soap php_http.c
Log:
MFB: Improved the error reporting in SOAP extension on request failure.
http://cvs.php.net/viewvc.cgi/php-src/ext/soap/php_http.c?r1=1.90&r2=1.91&diff_format=u
Index: php-src/ext/soap/php_http.c
diff -u php-src/ext/soap/php_http.c:1.90 php-src/ext/soap/php_http.c:1.91
--- php-src/ext/soap/php_http.c:1.90 Sat Apr 29 18:29:14 2006
+++ php-src/ext/soap/php_http.c Tue Jun 27 23:33:19 2006
@@ -17,7 +17,7 @@
| Dmitry Stogov <dmitry@zend.com> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_http.c,v 1.90 2006/04/29 18:29:14 fmk Exp $ */
+/* $Id: php_http.c,v 1.91 2006/06/27 23:33:19 iliaa Exp $ */
#include "php_soap.h"
#include "ext/standard/base64.h"
@@ -237,6 +237,7 @@
int http_status;
int content_type_xml = 0;
char *content_encoding;
+ char *http_msg = NULL;
zend_bool old_allow_url_fopen;
if (this_ptr == NULL || Z_TYPE_P(this_ptr) != IS_OBJECT) {
@@ -729,6 +730,14 @@
tmp++;
http_status = atoi(tmp);
}
+ tmp = strstr(tmp," ");
+ if (tmp != NULL) {
+ tmp++;
+ if (http_msg) {
+ efree(http_msg);
+ }
+ http_msg = estrdup(tmp);
+ }
efree(http_version);
/* Try and get headers again */
@@ -842,6 +851,9 @@
zend_hash_del(Z_OBJPROP_P(this_ptr), "httpsocket", sizeof("httpsocket"));
zend_hash_del(Z_OBJPROP_P(this_ptr), "_use_proxy", sizeof("_use_proxy"));
add_soap_fault(this_ptr, "HTTP", "Error Fetching http body, No Content-Length,
connection closed or chunked data", NULL, NULL TSRMLS_CC);
+ if (http_msg) {
+ efree(http_msg);
+ }
return FALSE;
}
@@ -1044,6 +1056,9 @@
efree(content_encoding);
efree(http_headers);
efree(http_body);
+ if (http_msg) {
+ efree(http_msg);
+ }
add_soap_fault(this_ptr, "HTTP", "Unknown Content-Encoding", NULL, NULL
TSRMLS_CC);
return FALSE;
}
@@ -1057,6 +1072,9 @@
efree(http_headers);
efree(http_body);
add_soap_fault(this_ptr, "HTTP", "Can't uncompress compressed
response", NULL, NULL TSRMLS_CC);
+ if (http_msg) {
+ efree(http_msg);
+ }
return FALSE;
}
efree(content_encoding);
@@ -1087,27 +1105,16 @@
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);
- }
+ add_soap_fault(this_ptr, "HTTP", http_msg, NULL, NULL TSRMLS_CC);
+ efree(http_msg);
return FALSE;
}
}
+ if (http_msg) {
+ efree(http_msg);
+ }
+
return TRUE;
}