Fixed many redirects problem on Proxy
This commit is contained in:
parent
01058659ab
commit
f5598237b2
@ -333,7 +333,7 @@ struct Request {
|
|||||||
MultipartFormData get_file_value(const char *key) const;
|
MultipartFormData get_file_value(const char *key) const;
|
||||||
|
|
||||||
// private members...
|
// private members...
|
||||||
size_t authorization_count_ = 1;
|
size_t authorization_count_ = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Response {
|
struct Response {
|
||||||
@ -3995,7 +3995,7 @@ inline bool Client::handle_request(Stream &strm, const Request &req,
|
|||||||
|
|
||||||
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
|
||||||
if ((res.status == 401 || res.status == 407) &&
|
if ((res.status == 401 || res.status == 407) &&
|
||||||
req.authorization_count_ == 1) {
|
req.authorization_count_ < 5) {
|
||||||
auto is_proxy = res.status == 407;
|
auto is_proxy = res.status == 407;
|
||||||
const auto &username =
|
const auto &username =
|
||||||
is_proxy ? proxy_digest_auth_username_ : digest_auth_username_;
|
is_proxy ? proxy_digest_auth_username_ : digest_auth_username_;
|
||||||
|
@ -185,15 +185,17 @@ void DigestAuthTestFromHTTPWatch(Client& cli) {
|
|||||||
for (auto path : paths) {
|
for (auto path : paths) {
|
||||||
auto res = cli.Get(path.c_str());
|
auto res = cli.Get(path.c_str());
|
||||||
ASSERT_TRUE(res != nullptr);
|
ASSERT_TRUE(res != nullptr);
|
||||||
EXPECT_EQ(400, res->status);
|
EXPECT_EQ(401, res->status);
|
||||||
}
|
}
|
||||||
|
|
||||||
cli.set_digest_auth("bad", "world");
|
// NOTE: Until httpbin.org fixes issue #46, the following test is commented
|
||||||
for (auto path : paths) {
|
// out. Plese see https://httpbin.org/digest-auth/auth/hello/world
|
||||||
auto res = cli.Get(path.c_str());
|
// cli.set_digest_auth("bad", "world");
|
||||||
ASSERT_TRUE(res != nullptr);
|
// for (auto path : paths) {
|
||||||
EXPECT_EQ(400, res->status);
|
// auto res = cli.Get(path.c_str());
|
||||||
}
|
// ASSERT_TRUE(res != nullptr);
|
||||||
|
// EXPECT_EQ(401, res->status);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +268,7 @@ void KeepAliveTest(Client& cli, bool basic) {
|
|||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
int count = paths.size();
|
int count = static_cast<int>(paths.size());
|
||||||
while (count--) {
|
while (count--) {
|
||||||
auto &res = responses[i++];
|
auto &res = responses[i++];
|
||||||
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n", res.body);
|
EXPECT_EQ("{\n \"authenticated\": true, \n \"user\": \"hello\"\n}\n", res.body);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user