Add zero-copy interface version of http_response_builder_body
This commit is contained in:
@@ -491,6 +491,54 @@ void http_response_builder_body(HTTP_ResponseBuilder builder, HTTP_String str)
|
||||
byte_queue_write(&conn->output, str.ptr, str.len);
|
||||
}
|
||||
|
||||
void http_response_builder_body_cap(HTTP_ResponseBuilder builder, int cap)
|
||||
{
|
||||
HTTP_ServerConn *conn = builder_to_conn(builder);
|
||||
if (conn == NULL)
|
||||
return;
|
||||
|
||||
if (conn->state != HTTP_SERVER_CONN_WAIT_HEADER) {
|
||||
append_special_headers(conn);
|
||||
conn->state = HTTP_SERVER_CONN_WAIT_BODY;
|
||||
}
|
||||
|
||||
if (conn->state != HTTP_SERVER_CONN_WAIT_BODY)
|
||||
return;
|
||||
|
||||
byte_queue_write_setmincap(&conn->output, cap);
|
||||
}
|
||||
|
||||
char *http_response_builder_body_buf(HTTP_ResponseBuilder builder, int *cap)
|
||||
{
|
||||
HTTP_ServerConn *conn = builder_to_conn(builder);
|
||||
if (conn == NULL)
|
||||
return NULL;
|
||||
|
||||
if (conn->state != HTTP_SERVER_CONN_WAIT_HEADER) {
|
||||
append_special_headers(conn);
|
||||
conn->state = HTTP_SERVER_CONN_WAIT_BODY;
|
||||
}
|
||||
|
||||
if (conn->state != HTTP_SERVER_CONN_WAIT_BODY)
|
||||
return NULL;
|
||||
|
||||
ByteView tmp = byte_queue_write_buf(&conn->output);
|
||||
*cap = tmp.len;
|
||||
return tmp.ptr;
|
||||
}
|
||||
|
||||
void http_response_builder_body_ack(HTTP_ResponseBuilder builder, int num)
|
||||
{
|
||||
HTTP_ServerConn *conn = builder_to_conn(builder);
|
||||
if (conn == NULL)
|
||||
return;
|
||||
|
||||
if (conn->state != HTTP_SERVER_CONN_WAIT_BODY)
|
||||
return;
|
||||
|
||||
byte_queue_write_ack(&conn->output, num);
|
||||
}
|
||||
|
||||
void http_response_builder_send(HTTP_ResponseBuilder builder)
|
||||
{
|
||||
HTTP_ServerConn *conn = builder_to_conn(builder);
|
||||
|
||||
Reference in New Issue
Block a user