Skip to content

Commit

Permalink
fix http with no content responses (delayed write)
Browse files Browse the repository at this point in the history
  • Loading branch information
boazsegev committed Dec 13, 2024
1 parent a082c42 commit ef79541
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
21 changes: 12 additions & 9 deletions fio-stl.h
Original file line number Diff line number Diff line change
Expand Up @@ -46329,13 +46329,6 @@ FIO_SFUNC void fio___http_controller_http1_on_finish_task(void *c_,
void *upgraded) {
fio___http_connection_s *c = (fio___http_connection_s *)c_;
c->suspend = 0;
if (c->state.http.buf.len) {
fio_io_write2(c->io,
.buf = (void *)c->state.http.buf.buf,
.len = c->state.http.buf.len,
.dealloc = FIO_STRING_FREE);
c->state.http.buf = FIO_STR_INFO0;
}

if (upgraded)
goto upgraded;
Expand Down Expand Up @@ -46392,8 +46385,18 @@ FIO_SFUNC void fio___http_controller_http1_on_finish_task(void *c_,
/** called once a request / response had finished */
FIO_SFUNC void fio___http_controller_http1_on_finish(fio_http_s *h) {
fio___http_connection_s *c = (fio___http_connection_s *)fio_http_cdata(h);
if (fio_http_is_streaming(h))
fio_io_write2(c->io, .buf = (char *)"0\r\n\r\n", .len = 5, .copy = 1);
if (c->state.http.buf.len) {
if (fio_http_is_streaming(h))
fio_string_write(&c->state.http.buf, FIO_STRING_REALLOC, "0\r\n\r\n", 5);
fio_io_write2(c->io,
.buf = (void *)c->state.http.buf.buf,
.len = c->state.http.buf.len,
.dealloc = FIO_STRING_FREE);
c->state.http.buf = FIO_STR_INFO0;
} else {
if (fio_http_is_streaming(h))
fio_io_write2(c->io, .buf = (char *)"0\r\n\r\n", .len = 5, .copy = 1);
}
if (c->log)
fio_http_write_log(h);
if (fio_http_is_upgraded(h))
Expand Down
21 changes: 12 additions & 9 deletions fio-stl/439 http.h
Original file line number Diff line number Diff line change
Expand Up @@ -1503,13 +1503,6 @@ FIO_SFUNC void fio___http_controller_http1_on_finish_task(void *c_,
void *upgraded) {
fio___http_connection_s *c = (fio___http_connection_s *)c_;
c->suspend = 0;
if (c->state.http.buf.len) {
fio_io_write2(c->io,
.buf = (void *)c->state.http.buf.buf,
.len = c->state.http.buf.len,
.dealloc = FIO_STRING_FREE);
c->state.http.buf = FIO_STR_INFO0;
}

if (upgraded)
goto upgraded;
Expand Down Expand Up @@ -1566,8 +1559,18 @@ FIO_SFUNC void fio___http_controller_http1_on_finish_task(void *c_,
/** called once a request / response had finished */
FIO_SFUNC void fio___http_controller_http1_on_finish(fio_http_s *h) {
fio___http_connection_s *c = (fio___http_connection_s *)fio_http_cdata(h);
if (fio_http_is_streaming(h))
fio_io_write2(c->io, .buf = (char *)"0\r\n\r\n", .len = 5, .copy = 1);
if (c->state.http.buf.len) {
if (fio_http_is_streaming(h))
fio_string_write(&c->state.http.buf, FIO_STRING_REALLOC, "0\r\n\r\n", 5);
fio_io_write2(c->io,
.buf = (void *)c->state.http.buf.buf,
.len = c->state.http.buf.len,
.dealloc = FIO_STRING_FREE);
c->state.http.buf = FIO_STR_INFO0;
} else {
if (fio_http_is_streaming(h))
fio_io_write2(c->io, .buf = (char *)"0\r\n\r\n", .len = 5, .copy = 1);
}
if (c->log)
fio_http_write_log(h);
if (fio_http_is_upgraded(h))
Expand Down

0 comments on commit ef79541

Please sign in to comment.