aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/httpclient.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenhttp/httpclient.cpp')
-rw-r--r--src/zenhttp/httpclient.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/zenhttp/httpclient.cpp b/src/zenhttp/httpclient.cpp
index 0544bf5c8..c77be8624 100644
--- a/src/zenhttp/httpclient.cpp
+++ b/src/zenhttp/httpclient.cpp
@@ -402,7 +402,14 @@ TEST_CASE("httpclient")
{
if (HttpServiceRequest.RelativeUri() == "yo")
{
- return HttpServiceRequest.WriteResponse(HttpResponseCode::OK, HttpContentType::kText, "hey man");
+ if (HttpServiceRequest.IsLocalMachineRequest())
+ {
+ return HttpServiceRequest.WriteResponse(HttpResponseCode::OK, HttpContentType::kText, "hey family");
+ }
+ else
+ {
+ return HttpServiceRequest.WriteResponse(HttpResponseCode::OK, HttpContentType::kText, "hey stranger");
+ }
}
return HttpServiceRequest.WriteResponse(HttpResponseCode::OK);
}
@@ -440,6 +447,7 @@ TEST_CASE("httpclient")
HttpClient::Response TestResponse = Client.Get("/test/yo");
CHECK(TestResponse.IsSuccess());
+ CHECK_EQ(TestResponse.AsText(), "hey family");
}
if (IsIPv6Capable())
@@ -452,6 +460,7 @@ TEST_CASE("httpclient")
HttpClient::Response TestResponse = Client.Get("/test/yo");
CHECK(TestResponse.IsSuccess());
+ CHECK_EQ(TestResponse.AsText(), "hey family");
}
{
@@ -463,6 +472,7 @@ TEST_CASE("httpclient")
HttpClient::Response TestResponse = Client.Get("/test/yo");
CHECK(TestResponse.IsSuccess());
+ CHECK_EQ(TestResponse.AsText(), "hey family");
}
# if 0
{
@@ -474,7 +484,9 @@ TEST_CASE("httpclient")
HttpClient::Response TestResponse = Client.Get("/test/yo");
CHECK(TestResponse.IsSuccess());
+ CHECK_EQ(TestResponse.AsText(), "hey family");
}
+ Sleep(20000);
# endif // 0
AsioServer->RequestExit();
}
@@ -483,7 +495,7 @@ TEST_CASE("httpclient")
# if ZEN_PLATFORM_WINDOWS
SUBCASE("httpsys")
{
- Ref<HttpServer> HttpSysServer = CreateHttpSysServer(HttpSysConfig{.ForceLoopback = true});
+ Ref<HttpServer> HttpSysServer = CreateHttpSysServer(HttpSysConfig{.ForceLoopback = false});
int Port = HttpSysServer->Initialize(7575, TmpDir.Path());
REQUIRE(Port != -1);
@@ -511,6 +523,7 @@ TEST_CASE("httpclient")
HttpClient::Response TestResponse = Client.Get("/test/yo");
CHECK(TestResponse.IsSuccess());
+ CHECK_EQ(TestResponse.AsText(), "hey family");
}
if (IsIPv6Capable())
@@ -523,6 +536,7 @@ TEST_CASE("httpclient")
HttpClient::Response TestResponse = Client.Get("/test/yo");
CHECK(TestResponse.IsSuccess());
+ CHECK_EQ(TestResponse.AsText(), "hey family");
}
{
@@ -534,6 +548,7 @@ TEST_CASE("httpclient")
HttpClient::Response TestResponse = Client.Get("/test/yo");
CHECK(TestResponse.IsSuccess());
+ CHECK_EQ(TestResponse.AsText(), "hey family");
}
# if 0
{
@@ -543,9 +558,11 @@ TEST_CASE("httpclient")
ZEN_INFO("Request using {}", Client.GetBaseUri());
- HttpClient::Response TestResponse = Client.Get("/test");
+ HttpClient::Response TestResponse = Client.Get("/test/yo");
CHECK(TestResponse.IsSuccess());
+ CHECK_EQ(TestResponse.AsText(), "hey family");
}
+ Sleep(20000);
# endif // 0
HttpSysServer->RequestExit();
}