File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,10 +7,6 @@ add_executable(helloworld helloworld.cpp)
77add_warnings_optimizations (helloworld )
88target_link_libraries (helloworld PUBLIC Crow::Crow )
99
10- add_executable (helloworld_inject helloworld_inject.cpp )
11- add_warnings_optimizations (helloworld_inject )
12- target_link_libraries (helloworld_inject PUBLIC Crow::Crow )
13-
1410# If compression is enabled, the example will be built
1511if ("compression" IN_LIST CROW_FEATURES)
1612 add_executable (example_compression example_compression.cpp )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -2796,3 +2796,35 @@ TEST_CASE("option_header_passed_in_full")
27962796 CHECK (res.find (ServerName) != std::string::npos);
27972797 app.stop ();
27982798}
2799+
2800+
2801+ TEST_CASE (" inject_header_via_set_haeder" )
2802+ {
2803+ crow::SimpleApp app;
2804+
2805+ CROW_ROUTE (app, " /" )
2806+ ([](const crow::request &req, crow::response &res) {
2807+ res.write (" Hello, world!" );
2808+ res.set_header (" X-Custom" , " safe\r\n Injected: yes" );
2809+ res.add_header (" X-Custom2" , " safe\r\n Injected: yes" );
2810+
2811+ res.end ();
2812+ // return "Hello, world!";
2813+ });
2814+
2815+ app.validate ();
2816+
2817+ auto _ = app.bindaddr (LOCALHOST_ADDRESS).port (45451 ).server_name (" lol" ).run_async ();
2818+ app.wait_for_server_start ();
2819+
2820+ {
2821+ //
2822+ auto resp = HttpClient::request (LOCALHOST_ADDRESS, 45451 ,
2823+ " GET / HTTP/1.0\r\n Host: localhost\r\n\r\n " );
2824+
2825+ CHECK (resp.find (" \r\n Injected" ) == std::string::npos);
2826+ }
2827+
2828+ app.stop ();
2829+ }
2830+
You can’t perform that action at this time.
0 commit comments