mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-15 01:08:27 +00:00
parent
59f5fdbb33
commit
0308d60cb2
2 changed files with 128 additions and 9 deletions
57
test/test.cc
57
test/test.cc
|
@ -816,6 +816,31 @@ TEST(HttpsToHttpRedirectTest, Redirect) {
|
|||
EXPECT_EQ(200, res->status);
|
||||
}
|
||||
|
||||
TEST(HttpsToHttpRedirectTest2, Redirect) {
|
||||
SSLClient cli("nghttp2.org");
|
||||
cli.set_follow_location(true);
|
||||
|
||||
Params params;
|
||||
params.emplace("url", "http://www.google.com");
|
||||
params.emplace("status_code", "302");
|
||||
|
||||
auto res = cli.Get("/httpbin/redirect-to", params, Headers{});
|
||||
ASSERT_TRUE(res);
|
||||
EXPECT_EQ(200, res->status);
|
||||
}
|
||||
|
||||
TEST(HttpsToHttpRedirectTest3, Redirect) {
|
||||
SSLClient cli("nghttp2.org");
|
||||
cli.set_follow_location(true);
|
||||
|
||||
Params params;
|
||||
params.emplace("url", "http://www.google.com");
|
||||
|
||||
auto res = cli.Get("/httpbin/redirect-to?status_code=302", params, Headers{});
|
||||
ASSERT_TRUE(res);
|
||||
EXPECT_EQ(200, res->status);
|
||||
}
|
||||
|
||||
TEST(RedirectToDifferentPort, Redirect) {
|
||||
Server svr8080;
|
||||
Server svr8081;
|
||||
|
@ -956,9 +981,8 @@ TEST(ErrorHandlerTest, ContentLength) {
|
|||
TEST(NoContentTest, ContentLength) {
|
||||
Server svr;
|
||||
|
||||
svr.Get("/hi", [](const Request & /*req*/, Response &res) {
|
||||
res.status = 204;
|
||||
});
|
||||
svr.Get("/hi",
|
||||
[](const Request & /*req*/, Response &res) { res.status = 204; });
|
||||
auto thread = std::thread([&]() { svr.listen(HOST, PORT); });
|
||||
|
||||
// Give GET time to get a few messages.
|
||||
|
@ -3979,7 +4003,7 @@ TEST(DecodeWithChunkedEncoding, BrotliEncoding) {
|
|||
}
|
||||
#endif
|
||||
|
||||
TEST(HttpsToHttpRedirectTest2, SimpleInterface) {
|
||||
TEST(HttpsToHttpRedirectTest, SimpleInterface) {
|
||||
Client cli("https://nghttp2.org");
|
||||
cli.set_follow_location(true);
|
||||
auto res =
|
||||
|
@ -3989,4 +4013,29 @@ TEST(HttpsToHttpRedirectTest2, SimpleInterface) {
|
|||
ASSERT_TRUE(res);
|
||||
EXPECT_EQ(200, res->status);
|
||||
}
|
||||
|
||||
TEST(HttpsToHttpRedirectTest2, SimpleInterface) {
|
||||
Client cli("https://nghttp2.org");
|
||||
cli.set_follow_location(true);
|
||||
|
||||
Params params;
|
||||
params.emplace("url", "http://www.google.com");
|
||||
params.emplace("status_code", "302");
|
||||
|
||||
auto res = cli.Get("/httpbin/redirect-to", params, Headers{});
|
||||
ASSERT_TRUE(res);
|
||||
EXPECT_EQ(200, res->status);
|
||||
}
|
||||
|
||||
TEST(HttpsToHttpRedirectTest3, SimpleInterface) {
|
||||
Client cli("https://nghttp2.org");
|
||||
cli.set_follow_location(true);
|
||||
|
||||
Params params;
|
||||
params.emplace("url", "http://www.google.com");
|
||||
|
||||
auto res = cli.Get("/httpbin/redirect-to?status_code=302", params, Headers{});
|
||||
ASSERT_TRUE(res);
|
||||
EXPECT_EQ(200, res->status);
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue