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

Improve Tunnel Server RESPONSE dumps #1975

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/clients/HttpTunneler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -296,15 +296,25 @@ Http::Tunneler::handleResponse(const bool eof)
}

if (!parsedOk) {
// XXX: This code and Server RESPONSE reporting code below duplicate
// HttpStateData::processReplyHeader() reporting code, including its problems.
debugs(11, 3, "Non-HTTP-compliant header:\n---------\n" << readBuf << "\n----------");
bailOnResponseError("malformed CONNECT response from peer", nullptr);
return;
}

/* We know the whole response is in parser now */
debugs(11, 2, "Tunnel Server " << connection);
debugs(11, 2, "Tunnel Server RESPONSE:\n---------\n" <<
hp->messageProtocol() << " " << hp->messageStatus() << " " << hp->reasonPhrase() << "\n" <<
hp->mimeHeader() <<
"----------");

HttpReply::Pointer rep = new HttpReply;
rep->sources |= Http::Message::srcHttp;
rep->sline.set(hp->messageProtocol(), hp->messageStatus());
if (!rep->parseHeader(*hp) && rep->sline.status() == Http::scOkay) {
bailOnResponseError("malformed CONNECT response from peer", nullptr);
bailOnResponseError("malformed CONNECT response headers mime block from peer", nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This specific change makes this bailOnResponseError() reason distinct from !parsedOk reason. The adjusted wording is a bit awkward, but it now matches the wording used by HttpStateData::processReplyHeader(). Since this PR reuses relevant processReplyHeader() code (with all its problems), I think this is the right change; it and can be viewed as being in this PR scope.

This comment does not request any changes.

return;
}

Expand All @@ -313,11 +323,6 @@ Http::Tunneler::handleResponse(const bool eof)
futureAnswer.peerResponseStatus = rep->sline.status();
request->hier.peer_reply_status = rep->sline.status();

debugs(11, 2, "Tunnel Server " << connection);
debugs(11, 2, "Tunnel Server RESPONSE:\n---------\n" <<
Raw(nullptr, readBuf.rawContent(), rep->hdr_sz).minLevel(2).gap(false) <<
"----------");

// bail if we did not get an HTTP 200 (Connection Established) response
if (rep->sline.status() != Http::scOkay) {
// TODO: To reuse the connection, extract the whole error response.
Expand Down