增加GZIP压缩功能及对应的单元测试

This commit is contained in:
Lu Qiuwen
2018-09-28 15:05:54 +08:00
parent 5bf18848c1
commit a14b665f90
5 changed files with 208 additions and 53 deletions

View File

@@ -332,10 +332,10 @@ static int __parser_callback_on_body(struct http_parser * parser, const char * a
/* Create ungzip context */
if (hf_private->content_encoding != HTTP_ACCEPT_ENCODING_NONE)
{
hf_private->cv_unpress_object = hf_content_converter_create(HF_CONTENT_CONV_UNCOMPRASS,
hf_private->cv_uncompress_object = hf_content_uncompress_create(
hf_private->content_encoding, hf_private->event_cb, hf_private->event_cb_user);
if (unlikely(hf_private->cv_unpress_object == NULL)) assert(0);
if (unlikely(hf_private->cv_uncompress_object == NULL)) assert(0);
}
hf_private->event_cb(hf_private, ev_body_begin, NULL, parser->content_length, hf_private->event_cb_user);
@@ -345,10 +345,10 @@ static int __parser_callback_on_body(struct http_parser * parser, const char * a
int ret = 0;
if (hf_private->event_cb && length != 0)
{
if (hf_private->cv_unpress_object != NULL)
if (hf_private->cv_uncompress_object != NULL)
{
ret = hf_content_converter_write(hf_private->cv_unpress_object, hf_private, ev_body_cont,
(const unsigned char *)at, length);
ret = hf_content_uncompress_write(hf_private->cv_uncompress_object, hf_private, ev_body_cont,
(const unsigned char *) at, length);
}
else
{