diff options
author | 2022-06-27 05:28:45 -0700 | |
---|---|---|
committer | 2022-06-27 05:28:45 -0700 | |
commit | f70784a6d14d7858076bb925216d204a7abc4b93 (patch) | |
tree | 2c90d2bdc7c6da4c417c97acb43457884b7016e4 | |
parent | 77a0f335cb0f18af4e03713583b98e0e1b024b33 (diff) | |
download | bun-f70784a6d14d7858076bb925216d204a7abc4b93.tar.gz bun-f70784a6d14d7858076bb925216d204a7abc4b93.tar.zst bun-f70784a6d14d7858076bb925216d204a7abc4b93.zip |
Fix data corruption bug in HTTP server
-rw-r--r-- | src/deps/_libusockets.h | 1 | ||||
-rw-r--r-- | src/deps/libuwsockets.cpp | 14 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/deps/_libusockets.h b/src/deps/_libusockets.h index 08410de0b..affe4dac5 100644 --- a/src/deps/_libusockets.h +++ b/src/deps/_libusockets.h @@ -245,6 +245,7 @@ void uws_res_write_header(int ssl, uws_res_t *res, const char *key, void uws_res_write_header_int(int ssl, uws_res_t *res, const char *key, size_t key_length, uint64_t value); void uws_res_end_without_body(int ssl, uws_res_t *res); +void uws_res_end_stream(int ssl, uws_res_t *res, bool close_connection); bool uws_res_write(int ssl, uws_res_t *res, const char *data, size_t length); uintmax_t uws_res_get_write_offset(int ssl, uws_res_t *res); bool uws_res_has_responded(int ssl, uws_res_t *res); diff --git a/src/deps/libuwsockets.cpp b/src/deps/libuwsockets.cpp index f854cafdb..6e4c81356 100644 --- a/src/deps/libuwsockets.cpp +++ b/src/deps/libuwsockets.cpp @@ -724,6 +724,16 @@ void uws_res_end(int ssl, uws_res_t *res, const char *data, size_t length, } } +void uws_res_end_stream(int ssl, uws_res_t *res, bool close_connection) { + if (ssl) { + uWS::HttpResponse<true> *uwsRes = (uWS::HttpResponse<true> *)res; + uwsRes->endWithoutBody(std::nullopt, close_connection); + } else { + uWS::HttpResponse<false> *uwsRes = (uWS::HttpResponse<false> *)res; + uwsRes->endWithoutBody(std::nullopt, close_connection); + } +} + void uws_res_pause(int ssl, uws_res_t *res) { if (ssl) { uWS::HttpResponse<true> *uwsRes = (uWS::HttpResponse<true> *)res; @@ -810,10 +820,10 @@ void uws_res_end_without_body(int ssl, uws_res_t *res) { bool uws_res_write(int ssl, uws_res_t *res, const char *data, size_t length) { if (ssl) { uWS::HttpResponse<true> *uwsRes = (uWS::HttpResponse<true> *)res; - return uwsRes->write(std::string_view(data)); + return uwsRes->write(std::string_view(data, length)); } uWS::HttpResponse<false> *uwsRes = (uWS::HttpResponse<false> *)res; - return uwsRes->write(std::string_view(data)); + return uwsRes->write(std::string_view(data, length)); } uintmax_t uws_res_get_write_offset(int ssl, uws_res_t *res) { if (ssl) { |