}
}
#endif
+
+ if (Config.readAheadGap <= 0) {
+ fatalf("read_ahead_gap must be greater than 0 bytes");
+ }
}
/** Parse a line containing an obsolete directive.
DOC_START
The amount of data the cache will buffer ahead of what has been
sent to the client when retrieving an object from another server.
+
+ This also influences the maximum network read(2)/write(2) sizes in some
+ circumstances. Reducing the size of this buffer will decrease
+ per-connection memory usage at the cost of more read(2)/write(2) calls.
+ Conversely, increasing the size of this buffer will decrease the number of
+ read(2)/write(2) calls at the cost of memory usage, potentially improving
+ performance.
+
+ Squid does not slow does the response delivery to the client in order to
+ fill the buffer.
+
DOC_END
NAME: negative_ttl
http->uri = xstrdup(uri);
setLogUri (http, uri);
auto *context = new Http::Stream(clientConnection, http);
- StoreIOBuffer tempBuffer;
- tempBuffer.data = context->reqbuf;
- tempBuffer.length = HTTP_REQBUF_SZ;
clientStreamInit(&http->client_stream, clientGetMoreData, clientReplyDetach,
clientReplyStatus, new clientReplyContext(http), clientSocketRecipient,
- clientSocketDetach, context, tempBuffer);
+ clientSocketDetach, context, context->getClientStreamBuffer());
return context;
}
http->req_sz = hp->messageHeaderSize();
Http::Stream *result = new Http::Stream(csd->clientConnection, http);
- StoreIOBuffer tempBuffer;
- tempBuffer.data = result->reqbuf;
- tempBuffer.length = HTTP_REQBUF_SZ;
-
ClientStreamData newServer = new clientReplyContext(http);
ClientStreamData newClient = result;
clientStreamInit(&http->client_stream, clientGetMoreData, clientReplyDetach,
clientReplyStatus, newServer, clientSocketRecipient,
- clientSocketDetach, newClient, tempBuffer);
+ clientSocketDetach, newClient, result->getClientStreamBuffer());
/* set url */
debugs(33,5, "Prepare absolute URL from " <<
#include "http/Stream.h"
#include "HttpHdrContRange.h"
#include "HttpHeaderTools.h"
+#include "SquidConfig.h"
#include "Store.h"
#include "TimeOrTag.h"
reply(nullptr),
writtenToSocket(0),
mayUseConnection_(false),
- connRegistered_(false)
+ connRegistered_(false),
+ requestBuffer(nullptr)
{
assert(http != nullptr);
- memset(reqbuf, '\0', sizeof (reqbuf));
flags.deferred = 0;
flags.parsed_ok = 0;
deferredparams.node = nullptr;
debugs(33, 5, reply << " written " << http->out.size << " into " << clientConnection);
/* More data will be coming from the stream. */
- StoreIOBuffer readBuffer;
+ StoreIOBuffer readBuffer = getClientStreamBuffer();
/* XXX: Next requested byte in the range sequence */
/* XXX: length = getmaximumrangelenfgth */
readBuffer.offset = getNextRangeOffset();
- readBuffer.length = HTTP_REQBUF_SZ;
- readBuffer.data = reqbuf;
/* we may note we have reached the end of the wanted ranges */
clientStreamRead(getTail(), http, readBuffer);
}
deferredparams.queuedBuffer = receivedData;
}
+StoreIOBuffer
+Http::Stream::getClientStreamBuffer()
+{
+ if (!requestBuffer) {
+ requestBuffer = new MemBlob(Config.readAheadGap);
+ }
+ StoreIOBuffer tempBuffer;
+ tempBuffer.data = requestBuffer->mem;
+ tempBuffer.length = requestBuffer->spaceSize();
+ return tempBuffer;
+}
+
void
Http::Stream::prepareReply(HttpReply *rep)
{
void deferRecipientForLater(clientStreamNode *, HttpReply *, StoreIOBuffer receivedData);
+ StoreIOBuffer getClientStreamBuffer();
+
public: // HTTP/1.x state data
Comm::ConnectionPointer clientConnection; ///< details about the client connection socket
ClientHttpRequest *http; /* we pretend to own that Job */
HttpReply *reply;
- char reqbuf[HTTP_REQBUF_SZ];
struct {
unsigned deferred:1; ///< This is a pipelined request waiting for the current object to complete
unsigned parsed_ok:1; ///< Was this parsed correctly?
bool mayUseConnection_; /* This request may use the connection. Don't read anymore requests for now */
bool connRegistered_;
+
+ MemBlob::Pointer requestBuffer;
};
} // namespace Http
Http::Stream *const result =
new Http::Stream(clientConnection, http);
- StoreIOBuffer tempBuffer;
- tempBuffer.data = result->reqbuf;
- tempBuffer.length = HTTP_REQBUF_SZ;
-
ClientStreamData newServer = new clientReplyContext(http);
ClientStreamData newClient = result;
clientStreamInit(&http->client_stream, clientGetMoreData, clientReplyDetach,
clientReplyStatus, newServer, clientSocketRecipient,
- clientSocketDetach, newClient, tempBuffer);
+ clientSocketDetach, newClient, result->getClientStreamBuffer());
result->flags.parsed_ok = 1;
return result;