@@ -267,7 +267,7 @@ static int http_request_on_query_string(swoole_http_parser *parser, const char *
267
267
268
268
static int http_request_on_header_field (swoole_http_parser *parser, const char *at, size_t length) {
269
269
HttpContext *ctx = (HttpContext *) parser->data ;
270
- ctx->current_header_name = ( char *) at;
270
+ ctx->current_header_name = at;
271
271
ctx->current_header_name_len = length;
272
272
return 0 ;
273
273
}
@@ -342,7 +342,7 @@ bool swoole_http_token_list_contains_value(const char *at, size_t length, const
342
342
static int http_request_on_header_value (swoole_http_parser *parser, const char *at, size_t length) {
343
343
HttpContext *ctx = (HttpContext *) parser->data ;
344
344
zval *zheader = ctx->request .zheader ;
345
- char *header_name = ctx->current_header_name ;
345
+ const char *header_name = ctx->current_header_name ;
346
346
size_t header_len = ctx->current_header_name_len ;
347
347
348
348
if (ctx->parse_cookie && SW_STRCASEEQ (header_name, header_len, " cookie" )) {
@@ -546,7 +546,11 @@ static int multipart_body_on_header_value(multipart_parser *p, const char *at, s
546
546
zval *z_multipart_header = sw_malloc_zval ();
547
547
array_init (z_multipart_header);
548
548
549
- add_assoc_string (z_multipart_header, " type" , (char *) " " );
549
+ if (ctx->tmp_content_type ) {
550
+ add_assoc_stringl (z_multipart_header, " type" , ctx->tmp_content_type , ctx->tmp_content_type_len );
551
+ } else {
552
+ add_assoc_string (z_multipart_header, " type" , (char *) " " );
553
+ }
550
554
add_assoc_string (z_multipart_header, " tmp_name" , (char *) " " );
551
555
add_assoc_long (z_multipart_header, " size" , 0 );
552
556
@@ -563,11 +567,16 @@ static int multipart_body_on_header_value(multipart_parser *p, const char *at, s
563
567
ctx->current_multipart_header = z_multipart_header;
564
568
}
565
569
zval_ptr_dtor (&tmp_array);
566
- } else if (SW_STRCASEEQ (header_name, header_len, " content-type" ) && ctx->current_multipart_header ) {
567
- zval *z_multipart_header = ctx->current_multipart_header ;
568
- zval *zerr = zend_hash_str_find (Z_ARRVAL_P (z_multipart_header), ZEND_STRL (" error" ));
569
- if (zerr && Z_TYPE_P (zerr) == IS_LONG && Z_LVAL_P (zerr) == HTTP_UPLOAD_ERR_OK) {
570
- add_assoc_stringl (z_multipart_header, " type" , (char *) at, length);
570
+ } else if (SW_STRCASEEQ (header_name, header_len, " content-type" )) {
571
+ if (ctx->current_multipart_header ) {
572
+ zval *z_multipart_header = ctx->current_multipart_header ;
573
+ zval *zerr = zend_hash_str_find (Z_ARRVAL_P (z_multipart_header), ZEND_STRL (" error" ));
574
+ if (zerr && Z_TYPE_P (zerr) == IS_LONG && Z_LVAL_P (zerr) == HTTP_UPLOAD_ERR_OK) {
575
+ add_assoc_stringl (z_multipart_header, " type" , (char *) at, length);
576
+ }
577
+ } else {
578
+ ctx->tmp_content_type = at;
579
+ ctx->tmp_content_type_len = length;
571
580
}
572
581
} else if (SW_STRCASEEQ (header_name, header_len, SW_HTTP_UPLOAD_FILE)) {
573
582
zval *z_multipart_header = ctx->current_multipart_header ;
0 commit comments