X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=php_http_message_body.c;h=c9cea55b46f640c4dab754082687c968afd1618c;hb=59ffe749e2571c7e4bf0cce12997f95f350bd58c;hp=8faf0a4d5bb21a622952aeab51bc9a009ee3149e;hpb=561d8510ce4f7d825de839257c556f032538f71e;p=m6w6%2Fext-http diff --git a/php_http_message_body.c b/php_http_message_body.c index 8faf0a4..c9cea55 100644 --- a/php_http_message_body.c +++ b/php_http_message_body.c @@ -251,8 +251,6 @@ PHP_HTTP_API STATUS php_http_message_body_add_field(php_http_message_body_t *bod PHP_HTTP_API STATUS php_http_message_body_add_file(php_http_message_body_t *body, const char *name, const char *ctype, const char *path, php_stream *in) { - php_stream_statbuf ssb = {{0}}; - php_stream_filter *tef = NULL; char *safe_name, *path_dup = estrdup(path); TSRMLS_FETCH_FROM_CTX(body->ts); @@ -262,38 +260,14 @@ PHP_HTTP_API STATUS php_http_message_body_add_file(php_http_message_body_t *body php_http_message_body_appendf( body, "Content-Disposition: attachment; name=\"%s\"; filename=\"%s\"" PHP_HTTP_CRLF - "Content-Type: %s" PHP_HTTP_CRLF, + "Content-Transfer-Encoding: binary" PHP_HTTP_CRLF + "Content-Type: %s" PHP_HTTP_CRLF + PHP_HTTP_CRLF, safe_name, basename(path_dup), ctype ); - - if (SUCCESS == php_stream_stat(in, &ssb)) { - php_http_message_body_appendf( - body, - "Content-Length: %zu" PHP_HTTP_CRLF - "" PHP_HTTP_CRLF, - ssb.sb.st_size - ); - } else { - php_http_message_body_append( - body, - ZEND_STRL( - "Transfer-Encoding: chunked" PHP_HTTP_CRLF - "" PHP_HTTP_CRLF - ) - ); - - if ((tef = php_http_filter_factory.create_filter("http.chunked_encode", NULL, 0 TSRMLS_CC))) { - php_stream_filter_append(&in->readfilters, tef); - } - } - php_stream_copy_to_stream_ex(in, php_http_message_body_stream(body), PHP_STREAM_COPY_ALL, NULL); BOUNDARY_CLOSE(body); - if (tef) { - php_stream_filter_remove(tef, 1 TSRMLS_CC); - } - efree(safe_name); efree(path_dup); @@ -312,7 +286,7 @@ static inline char *format_key(uint type, char *str, ulong num, const char *pref } else if (type == HASH_KEY_IS_STRING) { new_key = estrdup(str); } else { - estrdup(""); + new_key = estrdup(""); } return new_key;