修正由于HTTP流式构建应答时,由于真实应答晚于构建应答到达触发的问题
* 原实现在真实应答晚于构建应答到达时,仍然触发流式TCP写操作; * 现修正为该情况时,直接发送完整的构建应答而不是流式写。
This commit is contained in:
@@ -155,6 +155,7 @@ struct tfe_stream_write_ctx * tfe_stream_write_frag_start(const struct tfe_strea
|
|||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
this_conn->w_ctx.dir = dir;
|
this_conn->w_ctx.dir = dir;
|
||||||
this_conn->w_ctx._stream = _stream;
|
this_conn->w_ctx._stream = _stream;
|
||||||
this_conn->on_writing = 1;
|
this_conn->on_writing = 1;
|
||||||
|
|||||||
@@ -87,9 +87,15 @@ static int __write_http_half_to_line(const struct tfe_stream * stream,
|
|||||||
* and has been call body_begin, construct the header */
|
* and has been call body_begin, construct the header */
|
||||||
if (hf_private->evbuf_body != NULL && hf_private->write_ctx == NULL)
|
if (hf_private->evbuf_body != NULL && hf_private->write_ctx == NULL)
|
||||||
{
|
{
|
||||||
/* Alloc stream write ctx */
|
printf("frag write start, stream = %p, hf_private = %p\n", stream, hf_private);
|
||||||
hf_private->write_ctx = tfe_stream_write_frag_start(stream, dir);
|
|
||||||
if (unlikely(hf_private->write_ctx == NULL)) return -1;
|
/* Still need to send data(not call body_end()), need to write frag start
|
||||||
|
* Otherwise, means the body is ready, send out directly without frag */
|
||||||
|
if(hf_private->message_status < STATUS_COMPLETE)
|
||||||
|
{
|
||||||
|
hf_private->write_ctx = tfe_stream_write_frag_start(stream, dir);
|
||||||
|
assert(hf_private->write_ctx != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
ret = __write_http_half(hf_private, stream, dir);
|
ret = __write_http_half(hf_private, stream, dir);
|
||||||
if (unlikely(ret < 0)) return ret;
|
if (unlikely(ret < 0)) return ret;
|
||||||
|
|||||||
@@ -656,6 +656,8 @@ int hf_ops_body_end(struct tfe_http_half * half)
|
|||||||
|
|
||||||
hf_private->body_status = STATUS_COMPLETE;
|
hf_private->body_status = STATUS_COMPLETE;
|
||||||
hf_private->message_status = STATUS_COMPLETE;
|
hf_private->message_status = STATUS_COMPLETE;
|
||||||
|
|
||||||
|
printf("frag write end, stream = %p, hf_private = %p\n", hf_private->session->hc_private->stream, hf_private);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -853,6 +855,7 @@ void hs_ops_response_set(struct tfe_http_session * session, struct tfe_http_half
|
|||||||
|
|
||||||
assert(hs_private->hf_private_resp_user == NULL);
|
assert(hs_private->hf_private_resp_user == NULL);
|
||||||
hs_private->hf_private_resp_user = hf_private;
|
hs_private->hf_private_resp_user = hf_private;
|
||||||
|
hf_private->session = hs_private;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct tfe_http_half * hs_ops_request_create(struct tfe_http_session * session,
|
struct tfe_http_half * hs_ops_request_create(struct tfe_http_session * session,
|
||||||
|
|||||||
Reference in New Issue
Block a user