X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=php_http_message_body.c;h=e02c2e4377c30de80ac678d32a3e7f5b845de776;hb=61067d19cf03ad876954c2644ff9e37942b2ad67;hp=41f036c1cc2c29de97624a7534cab82f99cdc559;hpb=32580f1d50d0481c9069b65ef30d0acd59ada3bb;p=m6w6%2Fext-http diff --git a/php_http_message_body.c b/php_http_message_body.c index 41f036c..e02c2e4 100644 --- a/php_http_message_body.c +++ b/php_http_message_body.c @@ -263,7 +263,7 @@ PHP_HTTP_API STATUS php_http_message_body_add_file(php_http_message_body_t *body BOUNDARY_OPEN(body); php_http_message_body_appendf( body, - "Content-Disposition: attachment; name=\"%s\"; filename=\"%s\"" PHP_HTTP_CRLF + "Content-Disposition: form-data; name=\"%s\"; filename=\"%s\"" PHP_HTTP_CRLF "Content-Transfer-Encoding: binary" PHP_HTTP_CRLF "Content-Type: %s" PHP_HTTP_CRLF PHP_HTTP_CRLF, @@ -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; @@ -701,7 +707,7 @@ static size_t pass(void *cb_arg, const char *str, size_t len) PHP_METHOD(HttpMessageBody, toCallback) { - struct fcd fcd = {0}; + struct fcd fcd; long offset = 0, forlen = 0; if (SUCCESS == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "f|ll", &fcd.fci, &fcd.fcc, &offset, &forlen)) {