return space;
}
-size_t
-Client::replyBodySpace(const MemBuf &readBuf, const size_t minSpace) const
-{
- size_t space = readBuf.spaceSize(); // available space w/o heroic measures
- if (space < minSpace) {
- const size_t maxSpace = readBuf.potentialSpaceSize(); // absolute best
- space = min(minSpace, maxSpace); // do not promise more than asked
- }
-
-#if USE_ADAPTATION
- if (responseBodyBuffer) {
- return 0; // Stop reading if already overflowed waiting for ICAP to catch up
- }
-
- if (virginBodyDestination != nullptr) {
- /*
- * BodyPipe buffer has a finite size limit. We
- * should not read more data from the network than will fit
- * into the pipe buffer or we _lose_ what did not fit if
- * the response ends sooner that BodyPipe frees up space:
- * There is no code to keep pumping data into the pipe once
- * response ends and serverComplete() is called.
- *
- * If the pipe is totally full, don't register the read handler.
- * The BodyPipe will call our noteMoreBodySpaceAvailable() method
- * when it has free space again.
- */
- size_t adaptation_space =
- virginBodyDestination->buf().potentialSpaceSize();
-
- debugs(11,9, "Client may read up to min(" <<
- adaptation_space << ", " << space << ") bytes");
-
- if (adaptation_space < space)
- space = adaptation_space;
- }
-#endif
-
- return space;
-}
-
void adaptOrFinalizeReply();
void addVirginReplyBody(const char *buf, ssize_t len);
void storeReplyBody(const char *buf, ssize_t len);
- /// \deprecated use SBuf I/O API and calcBufferSpaceToReserve() instead
- size_t replyBodySpace(const MemBuf &readBuf, const size_t minSpace) const;
/// determine how much space the buffer needs to reserve
size_t calcBufferSpaceToReserve(const size_t space, const size_t wantSpace) const;
initReadBuf();
- const int read_sz = replyBodySpace(*data.readBuf, 0);
+ // XXX: We only use this call to decide whether to read; we never increase data.readBuf space.
+ // TODO: Upgrade data.readBuf to SBuf and merge this with similar HttpStateData::readReply() code.
+ const auto read_sz = calcBufferSpaceToReserve(data.readBuf->spaceSize(), data.readBuf->spaceSize());
debugs(9, 9, "FTP may read up to " << read_sz << " bytes");