#include "comm/Connection.h"
#include "comm/forward.h"
#include "comm/Write.h"
-#include "Server.h"
-#include "Store.h"
-#include "HttpRequest.h"
-#include "HttpReply.h"
-#include "errorpage.h"
#include "err_detail_type.h"
+#include "errorpage.h"
+#include "HttpReply.h"
+#include "HttpRequest.h"
+#include "protos.h"
+#include "Server.h"
#include "SquidTime.h"
+#include "StatCounters.h"
+#include "Store.h"
#if USE_ADAPTATION
#include "adaptation/AccessCheck.h"
// implemented in client_side_reply.cc until sides have a common parent
extern void purgeEntriesByUrl(HttpRequest * req, const char *url);
-
ServerStateData::ServerStateData(FwdState *theFwdState): AsyncJob("ServerStateData"),
requestSender(NULL),
#if USE_ADAPTATION
#endif
}
-
HttpReply *
ServerStateData::virginReply()
{
handleRequestBodyProducerAborted();
}
-
// more origin request body data is available
void
ServerStateData::handleMoreRequestBodyAvailable()
if (io.size > 0) {
fd_bytes(io.fd, io.size, FD_WRITE);
- kb_incr(&statCounter.server.all.kbytes_out, io.size);
+ kb_incr(&(statCounter.server.all.kbytes_out), io.size);
// kids should increment their counters
}
}
if (io.flag) {
- debugs(11, 1, "sentRequestBody error: FD " << io.fd << ": " << xstrerr(io.xerrno));
+ debugs(11, DBG_IMPORTANT, "sentRequestBody error: FD " << io.fd << ": " << xstrerr(io.xerrno));
ErrorState *err;
err = new ErrorState(ERR_WRITE_ERROR, HTTP_BAD_GATEWAY, fwd->request);
err->xerrno = io.xerrno;
if (!contentSize)
return; // XXX: bytesWanted asserts on zero-size ranges
- // XXX: entry->bytesWanted returns contentSize-1 if entry can accept data.
- // We have to add 1 to avoid suspending forever.
- const size_t bytesWanted = entry->bytesWanted(Range<size_t>(0, contentSize));
- const size_t spaceAvailable = bytesWanted > 0 ? (bytesWanted + 1) : 0;
+ const size_t spaceAvailable = entry->bytesWanted(Range<size_t>(0, contentSize), true);
if (spaceAvailable < contentSize ) {
// No or partial body data consuming
entry->deferProducer(call);
}
- // XXX: bytesWanted API does not allow us to write just one byte!
- if (!spaceAvailable && contentSize > 1) {
+ if (!spaceAvailable) {
debugs(11, 5, HERE << "NOT storing " << contentSize << " bytes of adapted " <<
"response body at offset " << adaptedBodySource->consumedSize());
return;
completeForwarding();
}
-
// common part of noteAdaptation*Aborted and noteBodyConsumerAborted methods
void
ServerStateData::handleAdaptationAborted(bool bypassable)
if (entry->isEmpty()) {
debugs(11,9, HERE << "creating ICAP error entry after ICAP failure");
ErrorState *err = new ErrorState(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request);
- err->xerrno = ERR_DETAIL_ICAP_RESPMOD_EARLY;
+ err->detailError(ERR_DETAIL_ICAP_RESPMOD_EARLY);
fwd->fail(err);
fwd->dontRetry(true);
} else if (request) { // update logged info directly
page_id = ERR_ACCESS_DENIED;
ErrorState *err = new ErrorState(page_id, HTTP_FORBIDDEN, request);
- err->xerrno = ERR_DETAIL_RESPMOD_BLOCK_EARLY;
+ err->detailError(ERR_DETAIL_RESPMOD_BLOCK_EARLY);
fwd->fail(err);
fwd->dontRetry(true);
ServerStateData::sendBodyIsTooLargeError()
{
ErrorState *err = new ErrorState(ERR_TOO_BIG, HTTP_FORBIDDEN, request);
- err->xerrno = errno;
fwd->fail(err);
fwd->dontRetry(true);
abortTransaction("Virgin body too large.");