Skip to content

Commit

Permalink
do not try to read 401 body after a Connection: close
Browse files Browse the repository at this point in the history
cntlm waited indefinitely when upstream's HTTP 401 included a pretty message body.
Resolution from Francesco MDE
  • Loading branch information
outtersg committed Mar 30, 2023
1 parent 2b2a2d6 commit 149d916
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions direct.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@ rr_data_t direct_request(void *cdata, rr_data_const_t request) {
if (debug)
printf("Reconnect before WWW auth\n");
close(sd);
/*
* Make sure nobody tries to read the body, particularly http_body_drop():
* now that we closed the socket, it would wait indefinitely.
*/
data[1]->headers = hlist_mod(data[1]->headers, "Content-Length", "0", 1);
sd = host_connect(data[0]->hostname, data[0]->port);
if (sd < 0) {
tmp = gen_502_page(data[0]->http, "WWW authentication reconnect failed");
Expand Down

0 comments on commit 149d916

Please sign in to comment.