Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring #109

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
29 changes: 14 additions & 15 deletions forward.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,14 @@ rr_data_t forward_request(void *thread_data, rr_data_t request) {
* - read proxy response
* - forward it to the client with HTTP body, if present
*
* There two goto's:
* - beginning: jump here to retry request (when cached connection timed out
* There is one goto to "beginning":
* - jump here to retry request (when cached connection timed out
* or we thought proxy was notauth, but got 407)
* - shortcut: jump here from 1st iter. of inner loop, when we detect
* that auth isn't required by proxy. We do loop++, make the jump and
* the reply to our auth attempt (containing valid response) is sent to
* client directly without us making a request a second time.
*
* During 1st iter. of inner loop (loop == 0), when we detect
* that auth isn't required by proxy, we set loop = 1 and
* the reply to our auth attempt (containing valid response) is sent to
* client directly without us making a request a second time.
*/
if (request) {
if (retry)
Expand Down Expand Up @@ -233,7 +234,6 @@ rr_data_t forward_request(void *thread_data, rr_data_t request) {
syslog(LOG_DEBUG, "%s %s %s", saddr, data[0]->method, data[0]->url);
}

shortcut:
/*
* Modify request headers.
*
Expand Down Expand Up @@ -307,7 +307,7 @@ rr_data_t forward_request(void *thread_data, rr_data_t request) {
* !!! that's why we reset data[1] below !!!
*
* Reply to auth request wasn't 407? Then auth is not required,
* let's jump into the next loop and forward it to client
* let's set loop = 1 so that we forward reply to client
* Also just forward if proxy doesn't reply with keep-alive,
* because without it, NTLM auth wouldn't work anyway.
*
Expand All @@ -320,14 +320,13 @@ rr_data_t forward_request(void *thread_data, rr_data_t request) {
if (data[1]->code < 400)
noauth = 1;
loop = 1;
goto shortcut;
fralken marked this conversation as resolved.
Show resolved Hide resolved
} else {
/*
* If we're continuing normally, we have to free possible
* auth response from proxy_authenticate() in data[1]
*/
reset_rr_data(data[1]);
}

/*
* If we're continuing normally, we have to free possible
* auth response from proxy_authenticate() in data[1]
*/
reset_rr_data(data[1]);
}

/*
Expand Down