Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
qicosmos committed Dec 13, 2024
1 parent fa894d6 commit e283947
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions include/cinatra/coro_http_connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ class coro_http_connection

if (!response_.get_delay()) {
if (head_buf_.size()) {
if (type == content_type::multipart) {
if (type == content_type::multipart ||
type == content_type::chunked) {
if (response_.content().empty())
response_.set_status_and_content(
status_type::not_implemented,
Expand All @@ -320,9 +321,8 @@ class coro_http_connection
}
else if (parser_.method()[0] != 'G' && parser_.method()[0] != 'H') {
// handle pipeling, only support GET and HEAD method now.
if (response_.content().empty())
response_.set_status_and_content(status_type::method_not_allowed,
"method not allowed");
response_.set_status_and_content(status_type::method_not_allowed,
"method not allowed");
co_await reply();
}
else {
Expand Down
5 changes: 4 additions & 1 deletion tests/test_cinatra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,9 @@ TEST_CASE("test pipeline") {
coro_http_server server(1, 9001);
server.set_http_handler<GET, POST>(
"/test", [](coro_http_request &req, coro_http_response &res) {
if (req.get_content_type() == content_type::multipart) {
return;
}
res.set_status_and_content(status_type::ok, "hello world");
});
server.set_http_handler<GET, POST>(
Expand Down Expand Up @@ -2355,7 +2358,7 @@ TEST_CASE("test multipart and chunked return error") {
std::string uri1 = "http://127.0.0.1:8090/no_such";
auto result = async_simple::coro::syncAwait(
client.async_upload_chunked(uri1, http_method::PUT, filename));
CHECK(result.status == 404);
CHECK(result.status != 200);
}
std::error_code ec;
fs::remove(filename, ec);
Expand Down

0 comments on commit e283947

Please sign in to comment.