@@ -738,6 +738,9 @@ TEST_CASE("test pipeline") {
738738 coro_http_server server (1 , 9001 );
739739 server.set_http_handler <GET, POST>(
740740 " /test" , [](coro_http_request &req, coro_http_response &res) {
741+ if (req.get_content_type () == content_type::multipart) {
742+ return ;
743+ }
741744 res.set_status_and_content (status_type::ok, " hello world" );
742745 });
743746 server.set_http_handler <GET, POST>(
@@ -2313,6 +2316,54 @@ TEST_CASE("test coro_http_client chunked upload and download") {
23132316 }
23142317}
23152318
2319+ TEST_CASE (" test multipart and chunked return error" ) {
2320+ coro_http_server server (1 , 8090 );
2321+ server.set_http_handler <cinatra::PUT, cinatra::POST>(
2322+ " /multipart" ,
2323+ [](request &req, response &resp) -> async_simple::coro::Lazy<void > {
2324+ resp.set_status_and_content (status_type::bad_request,
2325+ " invalid headers" );
2326+ co_return ;
2327+ });
2328+ server.set_http_handler <cinatra::PUT, cinatra::POST>(
2329+ " /chunked" ,
2330+ [](request &req, response &resp) -> async_simple::coro::Lazy<void > {
2331+ resp.set_status_and_content (status_type::bad_request,
2332+ " invalid headers" );
2333+ co_return ;
2334+ });
2335+ server.async_start ();
2336+
2337+ std::string filename = " small_test_file.txt" ;
2338+ create_file (filename, 10 );
2339+ {
2340+ coro_http_client client{};
2341+ std::string uri1 = " http://127.0.0.1:8090/chunked" ;
2342+ auto result = async_simple::coro::syncAwait (
2343+ client.async_upload_chunked (uri1, http_method::PUT, filename));
2344+ CHECK (result.resp_body == " invalid headers" );
2345+ }
2346+
2347+ {
2348+ coro_http_client client{};
2349+ std::string uri2 = " http://127.0.0.1:8090/multipart" ;
2350+ client.add_str_part (" test" , " test value" );
2351+ auto result =
2352+ async_simple::coro::syncAwait (client.async_upload_multipart (uri2));
2353+ CHECK (result.resp_body == " invalid headers" );
2354+ }
2355+
2356+ {
2357+ coro_http_client client{};
2358+ std::string uri1 = " http://127.0.0.1:8090/no_such" ;
2359+ auto result = async_simple::coro::syncAwait (
2360+ client.async_upload_chunked (uri1, http_method::PUT, filename));
2361+ CHECK (result.status != 200 );
2362+ }
2363+ std::error_code ec;
2364+ fs::remove (filename, ec);
2365+ }
2366+
23162367TEST_CASE (" test coro_http_client get" ) {
23172368 coro_http_client client{};
23182369 auto r = client.get (" http://www.baidu.com" );
@@ -3086,6 +3137,8 @@ TEST_CASE("test session") {
30863137 session_id_check_login = session->get_session_id ();
30873138 bool login = session->get_data <bool >(" login" ).value_or (false );
30883139 CHECK (login == true );
3140+ auto &all = session->get_all_data ();
3141+ CHECK (all.size () > 0 );
30893142 res.set_status (status_type::ok);
30903143 });
30913144 server.set_http_handler <GET>(
0 commit comments