修正构建HTTP应答时,同时填写Content-Length和Transfer-Encoding: Chunk报头,导致浏览器解析失败的问题。
This commit is contained in:
@@ -187,7 +187,7 @@ void __hf_public_req_fill_from_private(struct http_half_private * hf_private, st
|
||||
|
||||
/* Accept-Encoding */
|
||||
const static struct http_field_name __accept_encoding_name = {TFE_HTTP_ACCEPT_ENCODING, NULL};
|
||||
const char * __str_accept_encoding = tfe_http_field_read(hf_public, &__accept_encoding_name);
|
||||
const char * __str_accept_encoding = tfe_http_field_read(hf_public, &__accept_encoding_name);
|
||||
if (__str_accept_encoding != NULL)
|
||||
{
|
||||
hf_private->accept_content_encoding = __hf_content_encoding_parse(__str_accept_encoding);
|
||||
@@ -471,21 +471,32 @@ int hf_ops_field_write(struct tfe_http_half * half, const struct http_field_name
|
||||
__header_found = __header_iter; break;
|
||||
}
|
||||
|
||||
/* Found a header, update a value,
|
||||
* or insert a new header k-v in the tail of the header list */
|
||||
|
||||
if(__header_found != NULL)
|
||||
/* Update the value */
|
||||
if(__header_found != NULL && value != NULL)
|
||||
{
|
||||
if (__header_found->value != NULL) free(__header_found->value);
|
||||
free(__header_found->value);
|
||||
__header_found->value = tfe_strdup(value);
|
||||
}
|
||||
else
|
||||
/* Delete the key and value */
|
||||
else if (__header_found != NULL && value == NULL)
|
||||
{
|
||||
TAILQ_REMOVE(&hf_private->header_list, __header_found, next);
|
||||
free(__header_found->value);
|
||||
free(__header_found);
|
||||
}
|
||||
/* Insert a new header k-v in the tail of the header list */
|
||||
else if (__header_found == NULL && value != NULL)
|
||||
{
|
||||
struct http_header_private * __header = ALLOC(struct http_header_private, 1);
|
||||
__header->field = http_field_name_duplicate(field);
|
||||
__header->value = tfe_strdup(value);
|
||||
TAILQ_INSERT_TAIL(&hf_private->header_list, __header, next);
|
||||
}
|
||||
/* Nothing found, and delete nothing */
|
||||
else
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -537,7 +548,7 @@ int hf_ops_append_body(struct tfe_http_half * half, char * buff, size_t size, in
|
||||
if (hf_private->cv_compress_object)
|
||||
{
|
||||
ret = hf_content_compress_write(hf_private->cv_compress_object,
|
||||
(const unsigned char *)buff, size, hf_private->evbuf_body, 0);
|
||||
(const unsigned char *) buff, size, hf_private->evbuf_body, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -841,6 +852,10 @@ void hf_private_construct(struct http_half_private * hf_private)
|
||||
|
||||
const static struct http_field_name __cont_encoding_length_name = {TFE_HTTP_CONT_LENGTH, NULL};
|
||||
tfe_http_field_write(hf_public, &__cont_encoding_length_name, str_sz_evbuf_body);
|
||||
|
||||
/* If origin is chunked, now delete chunked tag */
|
||||
const static struct http_field_name __cont_transfer_encoding_name = {TFE_HTTP_TRANSFER_ENCODING, NULL};
|
||||
tfe_http_field_write(hf_public, &__cont_transfer_encoding_name, NULL);
|
||||
}
|
||||
|
||||
/* HTTP Request/Response first line */
|
||||
|
||||
Reference in New Issue
Block a user