dmitry Thu Jan 20 12:29:17 2005 EDT
Modified files:
/php-src/ext/soap php_http.c soap.c
Log:
Support for HTTP error codes
http://cvs.php.net/diff.php/php-src/ext/soap/php_http.c?r1=1.62&r2=1.63&ty=u
Index: php-src/ext/soap/php_http.c
diff -u php-src/ext/soap/php_http.c:1.62 php-src/ext/soap/php_http.c:1.63
--- php-src/ext/soap/php_http.c:1.62 Thu Jan 20 09:29:19 2005
+++ php-src/ext/soap/php_http.c Thu Jan 20 12:29:16 2005
@@ -17,7 +17,7 @@
| Dmitry Stogov <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_http.c,v 1.62 2005/01/20 14:29:19 dmitry Exp $ */
+/* $Id: php_http.c,v 1.63 2005/01/20 17:29:16 dmitry Exp $ */
#include "php_soap.h"
#include "ext/standard/base64.h"
@@ -584,24 +584,6 @@
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 @@
}
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;
}
http://cvs.php.net/diff.php/php-src/ext/soap/soap.c?r1=1.130&r2=1.131&ty=u
Index: php-src/ext/soap/soap.c
diff -u php-src/ext/soap/soap.c:1.130 php-src/ext/soap/soap.c:1.131
--- php-src/ext/soap/soap.c:1.130 Thu Jan 20 09:29:19 2005
+++ php-src/ext/soap/soap.c Thu Jan 20 12:29:16 2005
@@ -17,7 +17,7 @@
| Dmitry Stogov <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
*/
-/* $Id: soap.c,v 1.130 2005/01/20 14:29:19 dmitry Exp $ */
+/* $Id: soap.c,v 1.131 2005/01/20 17:29:16 dmitry Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -2142,7 +2142,9 @@
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) {
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php