Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
33 changes: 28 additions & 5 deletions src/client_side_reply.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1005,11 +1005,34 @@ clientReplyContext::traceReply()
triggerInitialStoreRead();
http->storeEntry()->releaseRequest();
http->storeEntry()->buffer();
const HttpReplyPointer rep(new HttpReply);
rep->setHeaders(Http::scOkay, nullptr, "text/plain", http->request->prefixLen(), 0, squid_curtime);
http->storeEntry()->replaceHttpReply(rep);
http->request->swapOut(http->storeEntry());
http->storeEntry()->complete();

auto *entry = http->storeEntry();

ErrorState err(HTTP_TRACE_REPLY, Http::scOkay, http->request, http->al);
err.url = xstrdup(entry->url());
auto *rep = err.BuildHttpReply();
// when there is no admin provided HTTP_TRACE_REPLY template
if (strncmp(rep->body.content(),"Internal Error:", 15) == 0) {
/**
* RFC 9110 section 9.3.8:
* The final recipient of the request SHOULD reflect the message received,
* back to the client as the content of a 200 (OK) response.
*
* The final recipient of the request SHOULD exclude any request fields
* that are likely to contain sensitive data when that recipient generates
* the response content.
*/
MemBuf content;
content.init();
http->request->pack(&content, true /* hide authorization data */);
rep->body.set(SBuf(content.buf, content.size));
rep->header.delById(Http::HdrType::CONTENT_LENGTH);
rep->header.putInt64(Http::HdrType::CONTENT_LENGTH, content.size);
rep->content_length = content.size;
}

entry->replaceHttpReply(rep);
entry->completeSuccessfully("TRACE response is atomic");
}

#define SENDING_BODY 0
Expand Down
5 changes: 5 additions & 0 deletions src/error/forward.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ typedef enum {
ERR_REQUEST_PARSE_TIMEOUT, // Aborts the connection instead of error page
ERR_RELAY_REMOTE, // Sends server reply instead of error page

// Reply message for TRACE requests is optional.
// HTTP specification default response (equivalent to '%R')
// will be generated if no template is found.
HTTP_TRACE_REPLY,

/* Cache Manager GUI can install a manager index/home page */
MGR_INDEX,

Expand Down
Loading