X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-http;a=blobdiff_plain;f=php_http_message_body.c;h=6129caff1a9bc4eb2e4af7171eb267f87f8ed196;hp=2749fac7f4bed3508558850dbf05c58d91badd91;hb=629c7b270b047582160c87b7c688c2b942a75d60;hpb=87db9817d428282792c8146d9c2ae9748ebf6f1e diff --git a/php_http_message_body.c b/php_http_message_body.c index 2749fac..6129caf 100644 --- a/php_http_message_body.c +++ b/php_http_message_body.c @@ -6,7 +6,7 @@ | modification, are permitted provided that the conditions mentioned | | in the accompanying LICENSE file are met. | +--------------------------------------------------------------------+ - | Copyright (c) 2004-2013, Michael Wallner | + | Copyright (c) 2004-2014, Michael Wallner | +--------------------------------------------------------------------+ */ @@ -55,6 +55,10 @@ php_http_message_body_t *php_http_message_body_init(php_http_message_body_t **bo } TSRMLS_SET_CTX(body->ts); + if (body_ptr) { + *body_ptr = body; + } + return body; } @@ -96,7 +100,7 @@ void php_http_message_body_free(php_http_message_body_t **body_ptr) TSRMLS_FETCH_FROM_CTX(body->ts); /* NOFIXME: shows leakinfo in DEBUG mode */ zend_list_delete(body->stream_id); - STR_FREE(body->boundary); + PTR_FREE(body->boundary); efree(body); } *body_ptr = NULL; @@ -478,9 +482,11 @@ static size_t splitbody(void *opaque, char *buf, size_t len TSRMLS_DC) } if (!first_boundary) { + int st; /* this is not the first boundary, read rest of this message */ php_http_buffer_append(&arg->buf, buf, real_boundary - buf); - php_http_message_parser_parse(arg->parser, &arg->buf, 0, &arg->parser->message); + st=php_http_message_parser_parse(arg->parser, &arg->buf, 0, &arg->parser->message); + //fprintf(stderr, "1 st=%d\n",st); } /* move after the boundary */ @@ -520,9 +526,11 @@ static size_t splitbody(void *opaque, char *buf, size_t len TSRMLS_DC) /* let there be room for the next boundary */ if (len > arg->boundary_len) { + int st; consumed += len - arg->boundary_len; php_http_buffer_append(&arg->buf, buf, len - arg->boundary_len); - php_http_message_parser_parse(arg->parser, &arg->buf, 0, &arg->parser->message); + st=php_http_message_parser_parse(arg->parser, &arg->buf, 0, &arg->parser->message); + //fprintf(stderr, "2 st=%d\n", st); } arg->consumed += consumed; @@ -553,7 +561,7 @@ php_http_message_t *php_http_message_body_split(php_http_message_body_t *body, c php_http_buffer_free(&tmp); php_http_message_parser_free(&arg.parser); php_http_buffer_dtor(&arg.buf); - STR_FREE(arg.boundary_str); + PTR_FREE(arg.boundary_str); return msg; }