Skip to content

Commit

Permalink
fix redir loop in response
Browse files Browse the repository at this point in the history
  • Loading branch information
janbar committed Nov 26, 2023
1 parent b6c1baf commit 5022b3c
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions noson/src/private/wsresponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,12 @@ WSResponse::WSResponse(const WSRequest &request, int maxRedirs, bool trustedLoca
: p(0)
{
p = new _response(request);
while (maxRedirs > 0)
while (0 < maxRedirs--)
{
--maxRedirs;
switch (p->GetStatusCode())
{
// handle redirection
case 301:
case 302:
int status = p->GetStatusCode();
if (status == 301 || status == 302)
{
// handle redirection
URIParser uri(p->Redirection());
bool trusted = (uri.Scheme() && strncmp("https", uri.Scheme(), 5) == 0);
if (
Expand All @@ -60,11 +57,10 @@ WSResponse::WSResponse(const WSRequest &request, int maxRedirs, bool trustedLoca
WSRequest redir(request, uri);
delete p;
p = new _response(redir);
continue;
}
}
default:
break;
}
break;
}
}

Expand Down

0 comments on commit 5022b3c

Please sign in to comment.