dmitry Wed Feb 18 01:58:34 2004 EDT
Modified files:
/php-src/ext/soap php_http.c
Log:
BUGFIX: HTTP chunked transfer-encoding support
http://cvs.php.net/diff.php/php-src/ext/soap/php_http.c?r1=1.42&r2=1.43&ty=u
Index: php-src/ext/soap/php_http.c
diff -u php-src/ext/soap/php_http.c:1.42 php-src/ext/soap/php_http.c:1.43
--- php-src/ext/soap/php_http.c:1.42 Mon Feb 16 04:56:30 2004
+++ php-src/ext/soap/php_http.c Wed Feb 18 01:58:33 2004
@@ -17,7 +17,7 @@
| Dmitry Stogov <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
*/
-/* $Id: php_http.c,v 1.42 2004/02/16 09:56:30 dmitry Exp $ */
+/* $Id: php_http.c,v 1.43 2004/02/18 06:58:33 dmitry Exp $ */
#include "php_soap.h"
#include "ext/standard/base64.h"
@@ -642,26 +642,41 @@
content_length = get_http_header_value(headers, "Content-Length: ");
if (trans_enc && !strcmp(trans_enc, "chunked")) {
- int buf_size = 0, len_size;
char done, chunk_size[10];
done = FALSE;
http_buf = NULL;
while (!done) {
- php_stream_gets(stream, chunk_size, sizeof(chunk_size));
-
- if (sscanf(chunk_size, "%x", &buf_size) != -1) {
- http_buf = erealloc(http_buf, http_buf_size + buf_size
+ 1);
- len_size = 0;
-
- while (http_buf_size < buf_size) {
- len_size += php_stream_read(stream, http_buf +
http_buf_size, buf_size - len_size);
- http_buf_size += len_size;
- }
+ int buf_size = 0;
+ php_stream_gets(stream, chunk_size, sizeof(chunk_size));
+ if (sscanf(chunk_size, "%x", &buf_size) > 0 ) {
+ if (buf_size > 0) {
+ int len_size = 0;
+
+ http_buf = erealloc(http_buf, http_buf_size +
buf_size + 1);
+
+ while (len_size < buf_size) {
+ int len_read = php_stream_read(stream,
http_buf + http_buf_size, buf_size - len_size);
+ if (len_read <= 0) {
+ /* Error or EOF */
+ done = TRUE;
+ break;
+ }
+ len_size += len_read;
+ http_buf_size += len_size;
+ }
+ }
+
/* Eat up '\r' '\n' */
- php_stream_getc(stream);php_stream_getc(stream);
+ php_stream_getc(stream);
+ php_stream_getc(stream);
+ } else {
+ /* Somthing wrong in chunked encoding */
+ efree(trans_enc);
+ efree(http_buf);
+ return FALSE;
}
if (buf_size == 0) {
done = TRUE;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php