class HttpControlMsg;
-/*
+/*
* This API exists to throttle forwarding of 1xx messages from the server
* side (Source == HttpStateData) to the client side (Sink == ConnStateData).
*
* Without throttling, Squid would have to drop some 1xx responses to
* avoid DoS attacks that send many 1xx responses without reading them.
* Dropping 1xx responses without violating HTTP is as complex as throttling.
- */
+ */
/// sends a single control message, notifying the Sink
class HttpControlMsgSink: public virtual AsyncJob
{
public:
typedef HttpMsgPointerT<HttpReply> MsgPtr;
- typedef AsyncCall::Pointer Callback;
+ typedef AsyncCall::Pointer Callback;
HttpControlMsg(const MsgPtr &aReply, const Callback &aCallback):
- reply(aReply), cbSuccess(aCallback) {}
+ reply(aReply), cbSuccess(aCallback) {}
public:
MsgPtr reply; ///< the 1xx message being forwarded
if (!requestBodySource->exhausted())
sendMoreRequestBody();
- else
- if (receivedWholeRequestBody)
+ else if (receivedWholeRequestBody)
doneSendingRequestBody();
else
debugs(9,3, HERE << "waiting for body production end or abort");
return; // can accumulte more header data
debugs(33, 3, "Request header is too large (" << in.notYetUsed << " > " <<
- Config.maxRequestHeaderSize << " bytes)");
+ Config.maxRequestHeaderSize << " bytes)");
ClientSocketContext *context = parseHttpRequestAbort(this, "error:request-too-large");
clientStreamNode *node = context->getClientReplyContext();
// HTTP/1.1 requires chunking to be the last encoding if there is one
unsupportedTe = te.size() && te != "identity";
} // else implied identity coding
-
+
if (method == METHOD_TRACE || method == METHOD_OPTIONS)
request->max_forwards = request->header.getInt64(HDR_MAX_FORWARDS);
expectBody = chunked || request->content_length > 0;
if (!context->mayUseConnection() && expectBody) {
request->body_pipe = conn->expectRequestBody(
- chunked ? -1 : request->content_length);
+ chunked ? -1 : request->content_length);
// consume header early so that body pipe gets just the body
connNoteUseOfBuffer(conn, http->req_sz);
/* Is it too large? */
if (!chunked && // if chunked, we will check as we accumulate
- clientIsRequestBodyTooLargeForPolicy(request->content_length)) {
+ clientIsRequestBodyTooLargeForPolicy(request->content_length)) {
clientStreamNode *node = context->getClientReplyContext();
clientReplyContext *repContext = dynamic_cast<clientReplyContext *>(node->data.getRaw());
assert (repContext);
// We may stop producing, comm_close, and/or call setReplyToError()
// below, so quit on errors to avoid http->doCallouts()
if (!conn->handleRequestBodyData())
- goto finish;
+ goto finish;
if (!request->body_pipe->productionEnded())
conn->readSomeData();
// Loop while we have read bytes that are not needed for producing the body
// On errors, bodyPipe may become nil, but readMoreRequests will be cleared
while (conn->in.notYetUsed > 0 && !conn->bodyPipe &&
- conn->flags.readMoreRequests) {
+ conn->flags.readMoreRequests) {
connStripBufferWhitespace (conn);
/* Don't try to parse if the buffer is empty */
clientReplyContext *repContext = dynamic_cast<clientReplyContext*>(node->data.getRaw());
assert(repContext);
const http_status scode = (error == ERR_TOO_BIG) ?
- HTTP_REQUEST_ENTITY_TOO_LARGE : HTTP_BAD_REQUEST;
+ HTTP_REQUEST_ENTITY_TOO_LARGE : HTTP_BAD_REQUEST;
repContext->setReplyToError(error, scode,
repContext->http->request->method,
repContext->http->uri,
context->pullData();
} else {
// close or otherwise we may get stuck as nobody will notice the error?
- comm_reset_close(fd);
+ comm_reset_close(fd);
}
#else
debugs(33, 3, HERE << "aborting chunked request without error " << error);
debugs(11, 3, HERE << "ignoring denied 1xx");
proceedAfter1xx();
return;
- }
+ }
}
#endif // USE_HTTP_VIOLATIONS
// the Sink will use this to call us back after writing 1xx to the client
typedef NullaryMemFunT<HttpStateData> CbDialer;
const AsyncCall::Pointer cb = JobCallback(11, 3, CbDialer, this,
- HttpStateData::proceedAfter1xx);
+ HttpStateData::proceedAfter1xx);
CallJobHere1(11, 4, orig_request->clientConnection, ConnStateData,
ConnStateData::sendControlMsg, HttpControlMsg(msg, cb));
// If the call is not fired, then the Sink is gone, and HttpStateData
Must(flags.handling1xx);
debugs(11, 2, HERE << "consuming " << header_bytes_read <<
- " header and " << reply_bytes_read << " body bytes read after 1xx");
+ " header and " << reply_bytes_read << " body bytes read after 1xx");
header_bytes_read = 0;
reply_bytes_read = 0;
/// processes the already read and buffered response data, possibly after
/// waiting for asynchronous 1xx control message processing
void
-HttpStateData::processReply() {
+HttpStateData::processReply()
+{
if (flags.handling1xx) { // we came back after handling a 1xx response
debugs(11, 5, HERE << "done with 1xx handling");
if (receivedWholeRequestBody) {
Must(!flags.sentLastChunk);
flags.sentLastChunk = true;
- buf.append("0\r\n\r\n", 5);
+ buf.append("0\r\n\r\n", 5);
}
return true;