feat: response bodies from char buffers; generated responses
This commit is contained in:
parent
62348c14f5
commit
2fb3e2bb00
12 changed files with 163 additions and 108 deletions
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
#include "event_loop.h"
|
||||
|
||||
void event_loop_conn_io_res(event_loop_conn *conn) {
|
||||
while (1) {
|
||||
void event_loop_conn_io_res(event_loop *el, event_loop_conn *conn) {
|
||||
do {
|
||||
ssize_t res = 0;
|
||||
size_t remain = conn->wbuf_size - conn->wbuf_sent;
|
||||
|
||||
|
|
@ -28,17 +28,15 @@ void event_loop_conn_io_res(event_loop_conn *conn) {
|
|||
|
||||
conn->wbuf_sent += (size_t)res;
|
||||
|
||||
// After writing a response, we switch back to request mode to process a
|
||||
// next request
|
||||
// After writing the entire buffer, we run the write_data command to receive
|
||||
// new data, or exit the loop
|
||||
if (conn->wbuf_sent == conn->wbuf_size) {
|
||||
conn->state = conn->close_after_write ? event_loop_conn_state_end
|
||||
: event_loop_conn_state_req;
|
||||
/* c->wbuf_sent = 0; */
|
||||
/* c->wbuf_size = 0; */
|
||||
conn->wbuf_sent = 0;
|
||||
conn->wbuf_size = 0;
|
||||
|
||||
return;
|
||||
el->write_data(conn);
|
||||
}
|
||||
}
|
||||
} while (conn->state == event_loop_conn_state_res);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -93,7 +91,7 @@ void event_loop_conn_io(event_loop *el, event_loop_conn *conn) {
|
|||
event_loop_conn_io_req(el, conn);
|
||||
break;
|
||||
case event_loop_conn_state_res:
|
||||
event_loop_conn_io_res(conn);
|
||||
event_loop_conn_io_res(el, conn);
|
||||
break;
|
||||
case event_loop_conn_state_end:;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue