add some more tests; fix leak in php_http_env_get_response_header(); honor content...
[m6w6/ext-http] / php_http_message_body.c
index 34b44f898b91c7935226298720148caf8cdb6580..e02c2e4377c30de80ac678d32a3e7f5b845de776 100644 (file)
@@ -425,6 +425,7 @@ static size_t splitbody(void *opaque, char *buf, size_t len TSRMLS_DC)
                if ((boundary = php_http_locate_str(buf, len, arg->boundary_str + first_boundary, arg->boundary_len - first_boundary))) {
                        size_t real_boundary_len = arg->boundary_len - 1, cut;
                        const char *real_boundary = boundary + !first_boundary;
+                       int eol_len = 0;
 
                        if (buf + len <= real_boundary + real_boundary_len) {
                                /* if we just have enough data for the boundary, it's just a byte too less */
@@ -444,7 +445,12 @@ static size_t splitbody(void *opaque, char *buf, size_t len TSRMLS_DC)
                        len -= cut;
                        consumed += cut;
 
-                       if (buf == php_http_locate_bin_eol(buf, len, NULL)) {
+                       if (buf == php_http_locate_bin_eol(buf, len, &eol_len)) {
+                               /* skip CRLF */
+                               buf += eol_len;
+                               len -= eol_len;
+                               consumed += eol_len;
+
                                if (!first_boundary) {
                                        /* advance messages */
                                        php_http_message_t *msg;