diff --git a/plugin/protocol/http/src/http_entry.cpp b/plugin/protocol/http/src/http_entry.cpp index a947181..5421e51 100644 --- a/plugin/protocol/http/src/http_entry.cpp +++ b/plugin/protocol/http/src/http_entry.cpp @@ -75,8 +75,9 @@ static int __write_http_half_to_line(const struct tfe_stream * stream, if (hf_private->is_setup_by_stream) { - /* By stream, first time to write http request/response, construct the header */ - if (hf_private->write_ctx == NULL) + /* By stream, first time to write http request/response, + * and has been call body_begin, construct the header */ + if (hf_private->evbuf_body != NULL && hf_private->write_ctx == NULL) { ret = __write_http_half(hf_private, stream, dir); if (unlikely(ret < 0)) return ret; diff --git a/plugin/protocol/http/src/http_half.cpp b/plugin/protocol/http/src/http_half.cpp index 58deb00..af3a836 100644 --- a/plugin/protocol/http/src/http_half.cpp +++ b/plugin/protocol/http/src/http_half.cpp @@ -587,15 +587,19 @@ int hf_ops_append_body(struct tfe_http_half * half, char * buff, size_t size, in int hf_ops_body_begin(struct tfe_http_half * half, int by_stream) { struct http_half_private * hf_private = to_hf_private(half); - assert(hf_private->evbuf_body == NULL); - if (hf_private->evbuf_body != NULL) - { - evbuffer_free(hf_private->evbuf_body); - } if (by_stream) { + /* By stream, we do not support content-encoding for now, + * send body directly without compression */ + if(hf_private->cv_compress_object != NULL) + { + hf_content_compress_destroy(hf_private->cv_compress_object); + hf_private->cv_compress_object = NULL; + } + + hf_private->content_encoding = HTTP_ACCEPT_ENCODING_NONE; hf_private->is_setup_by_stream = true; } @@ -682,9 +686,9 @@ struct tfe_http_half_ops __http_half_ops = .ops_http_allow_write = hf_ops_allow_write, .ops_http_field_iterate = hf_ops_field_iterate, .ops_append_body = hf_ops_append_body, - .ops_body_begin = NULL, - .ops_body_data = NULL, - .ops_body_end = NULL, + .ops_body_begin = hf_ops_body_begin, + .ops_body_data = hf_ops_body_data, + .ops_body_end = hf_ops_body_end, .ops_free = hf_ops_free };