year bump
[m6w6/ext-http] / http_api.c
index 4fa8c3d5b703203f92b84c083e421500bc7f8a9b..5599ef5db845224961abc685fa3ad2375d56a70d 100644 (file)
@@ -6,7 +6,7 @@
     | modification, are permitted provided that the conditions mentioned |
     | in the accompanying LICENSE file are met.                          |
     +--------------------------------------------------------------------+
-    | Copyright (c) 2004-2007, Michael Wallner <mike@php.net>            |
+    | Copyright (c) 2004-2010, Michael Wallner <mike@php.net>            |
     +--------------------------------------------------------------------+
 */
 
@@ -180,7 +180,10 @@ zval *_http_exception_wrap(zval *old_exception, zval *new_exception, zend_class_
                copy_bt_args(old_exception, new_exception TSRMLS_CC);
                copy_bt_args(old_exception, sub_exception TSRMLS_CC);
        }
-       
+#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3
+       Z_ADDREF_P(old_exception);
+       zend_exception_set_previous(new_exception, old_exception TSRMLS_CC);
+#endif
        zval_ptr_dtor(&old_exception);
        return new_exception;
 }
@@ -357,6 +360,9 @@ PHP_HTTP_API STATUS _http_get_request_body_ex(char **body, size_t *length, zend_
                        memcpy(*body + *length, buf, len);
                        *length += len;
                        (*body)[*length] = '\0';
+                       if (len < (int) sizeof(buf)) {
+                               break;
+                       }
                }
                
                /* check for error */
@@ -395,6 +401,9 @@ PHP_HTTP_API php_stream *_http_get_request_body_stream(TSRMLS_D)
                        
                        while (0 < (len = sapi_module.read_post(buf, sizeof(buf) TSRMLS_CC))) {
                                php_stream_write(s, buf, len);
+                               if (len < (int) sizeof(buf)) {
+                                       break;
+                               }
                        }
                        
                        if (len < 0) {