{
ClientSocketContext::Pointer *tempContextPointer;
assert(conn != NULL && cbdataReferenceValid(conn));
- assert(conn->getCurrentContext() != NULL);
+ assert(conn->currentobject != NULL);
/* Unlink us from the connection request list */
tempContextPointer = & conn->currentobject;
return 0;
}
-// careful: the "current" context may be gone if we wrote an early response
-ClientSocketContext::Pointer
-ConnStateData::getCurrentContext() const
-{
- return currentobject;
-}
-
void
ClientSocketContext::deferRecipientForLater(clientStreamNode * node, HttpReply * rep, StoreIOBuffer receivedData)
{
/* TODO: check offset is what we asked for */
- if (context != http->getConn()->getCurrentContext())
+ // TODO: enforces HTTP/1 MUST on pipeline order, but is irrelevant to HTTP/2
+ if (context != http->getConn()->pipeline.front())
context->deferRecipientForLater(node, rep, receivedData);
else
http->getConn()->handleReply(rep, receivedData);
return;
}
- ClientSocketContext::Pointer deferredRequest;
-
/** \par
* At this point we either have a parsed request (which we've
* kicked off the processing for) or not. If we have a deferred
* then look at processing it. If not, simply kickstart
* another read.
*/
-
- if ((deferredRequest = getCurrentContext()).getRaw()) {
+ ClientSocketContext::Pointer deferredRequest = pipeline.front();
+ if (deferredRequest != nullptr) {
debugs(33, 3, clientConnection << ": calling PushDeferredIfNeeded");
ClientSocketContextPushDeferredIfNeeded(deferredRequest, this);
} else if (flags.readMore) {
// but if we fail when the server connection is used already, the server may send
// us its response too, causing various assertions. How to prevent that?
#if WE_KNOW_HOW_TO_SEND_ERRORS
- ClientSocketContext::Pointer context = getCurrentContext();
+ ClientSocketContext::Pointer context = pipeline.front();
if (context != NULL && !context->http->out.offset) { // output nothing yet
clientStreamNode *node = context->getClientReplyContext();
clientReplyContext *repContext = dynamic_cast<clientReplyContext*>(node->data.getRaw());
transferProtocol = Http::ProtocolVersion();
// inBuf still has the "CONNECT ..." request data, reset it to SSL hello message
inBuf.append(rbuf.content(), rbuf.contentSize());
- ClientSocketContext::Pointer context = getCurrentContext();
+ ClientSocketContext::Pointer context = pipeline.front();
ClientHttpRequest *http = context->http;
tunnelStart(http);
}
Must(!bodyPipe); // we rely on it being nil after we are done with body
if (withSuccess) {
Must(myPipe->bodySizeKnown());
- ClientSocketContext::Pointer context = getCurrentContext();
+ ClientSocketContext::Pointer context = pipeline.front();
if (context != NULL && context->http && context->http->request)
context->http->request->setContentLength(myPipe->bodySize());
}
return;
}
- ClientSocketContext::Pointer context = getCurrentContext();
- if (context != NULL) {
+ auto context = pipeline.front();
+ if (context != nullptr) {
context->writeControlMsg(msg); // will call msg.cbSuccess
return;
}
Ftp::Server::doProcessRequest()
{
// zero pipelinePrefetchMax() ensures that there is only parsed request
- ClientSocketContext::Pointer context = getCurrentContext();
- Must(context != NULL);
Must(pipeline.count() == 1);
+ ClientSocketContext::Pointer context = pipeline.front();
+ Must(context != nullptr);
ClientHttpRequest *const http = context->http;
assert(http != NULL);
Ftp::Server::notePeerConnection(Comm::ConnectionPointer conn)
{
// find request
- ClientSocketContext::Pointer context = getCurrentContext();
- Must(context != NULL);
+ ClientSocketContext::Pointer context = pipeline.front();
+ Must(context != nullptr);
ClientHttpRequest *const http = context->http;
Must(http != NULL);
HttpRequest *const request = http->request;
Ftp::Server::handleReply(HttpReply *reply, StoreIOBuffer data)
{
// the caller guarantees that we are dealing with the current context only
- ClientSocketContext::Pointer context = getCurrentContext();
- assert(context != NULL);
+ ClientSocketContext::Pointer context = pipeline.front();
+ assert(context != nullptr);
if (context->http && context->http->al != NULL &&
!context->http->al->reply && reply) {
void
Ftp::Server::handleFeatReply(const HttpReply *reply, StoreIOBuffer)
{
- if (getCurrentContext()->http->request->errType != ERR_NONE) {
+ if (pipeline.front()->http->request->errType != ERR_NONE) {
writeCustomReply(502, "Server does not support FEAT", reply);
return;
}
void
Ftp::Server::handlePasvReply(const HttpReply *reply, StoreIOBuffer)
{
- ClientSocketContext::Pointer context = getCurrentContext();
- assert(context != NULL);
+ const ClientSocketContext::Pointer context(pipeline.front());
+ assert(context != nullptr);
if (context->http->request->errType != ERR_NONE) {
writeCustomReply(502, "Server does not support PASV", reply);
void
Ftp::Server::handlePortReply(const HttpReply *reply, StoreIOBuffer)
{
- if (getCurrentContext()->http->request->errType != ERR_NONE) {
+ if (pipeline.front()->http->request->errType != ERR_NONE) {
writeCustomReply(502, "Server does not support PASV (converted from PORT)", reply);
return;
}
AsyncCall::Pointer call = JobCallback(33, 5, Dialer, this, Ftp::Server::wroteReplyData);
Comm::Write(dataConn, &mb, call);
- getCurrentContext()->noteSentBodyBytes(data.length);
+ pipeline.front()->noteSentBodyBytes(data.length);
}
/// called when we are done writing a chunk of the response data
return;
}
- assert(getCurrentContext()->http);
- getCurrentContext()->http->out.size += io.size;
+ assert(pipeline.front()->http);
+ pipeline.front()->http->out.size += io.size;
replyDataWritingCheckpoint();
}
void
Ftp::Server::replyDataWritingCheckpoint()
{
- switch (getCurrentContext()->socketState()) {
+ switch (pipeline.front()->socketState()) {
case STREAM_NONE:
debugs(33, 3, "Keep going");
- getCurrentContext()->pullData();
+ pipeline.front()->pullData();
return;
case STREAM_COMPLETE:
debugs(33, 3, "FTP reply data transfer successfully complete");
void
Ftp::Server::handleEprtReply(const HttpReply *reply, StoreIOBuffer)
{
- if (getCurrentContext()->http->request->errType != ERR_NONE) {
+ if (pipeline.front()->http->request->errType != ERR_NONE) {
writeCustomReply(502, "Server does not support PASV (converted from EPRT)", reply);
return;
}
void
Ftp::Server::handleEpsvReply(const HttpReply *reply, StoreIOBuffer)
{
- if (getCurrentContext()->http->request->errType != ERR_NONE) {
+ if (pipeline.front()->http->request->errType != ERR_NONE) {
writeCustomReply(502, "Cannot connect to server", reply);
return;
}
void
Ftp::Server::writeErrorReply(const HttpReply *reply, const int scode)
{
- const HttpRequest *request = getCurrentContext()->http->request;
+ const HttpRequest *request = pipeline.front()->http->request;
assert(request);
MemBuf mb;
return;
}
- ClientSocketContext::Pointer context = getCurrentContext();
- if (context != NULL && context->http) {
+ ClientSocketContext::Pointer context = pipeline.front();
+ if (context != nullptr && context->http) {
context->http->out.size += io.size;
context->http->out.headers_sz += io.size;
}
return;
}
- ClientSocketContext::Pointer context = getCurrentContext();
+ ClientSocketContext::Pointer context = pipeline.front();
assert(context->http);
context->http->out.size += io.size;
context->http->out.headers_sz += io.size;
return false;
if (Config.accessList.forceRequestBodyContinuation) {
- ClientHttpRequest *http = getCurrentContext()->http;
+ ClientHttpRequest *http = pipeline.front()->http;
HttpRequest *request = http->request;
ACLFilledChecklist bodyContinuationCheck(Config.accessList.forceRequestBodyContinuation, request, NULL);
if (bodyContinuationCheck.fastCheck() == ACCESS_ALLOWED) {
void
Ftp::Server::setDataCommand()
{
- ClientHttpRequest *const http = getCurrentContext()->http;
+ ClientHttpRequest *const http = pipeline.front()->http;
assert(http != NULL);
HttpRequest *const request = http->request;
assert(request != NULL);
if (params.conn != NULL)
params.conn->close();
setReply(425, "Cannot open data connection.");
- ClientSocketContext::Pointer context = getCurrentContext();
+ ClientSocketContext::Pointer context = pipeline.front();
Must(context->http);
Must(context->http->storeEntry() != NULL);
} else {
void
Ftp::Server::setReply(const int code, const char *msg)
{
- ClientSocketContext::Pointer context = getCurrentContext();
+ ClientSocketContext::Pointer context = pipeline.front();
ClientHttpRequest *const http = context->http;
assert(http != NULL);
assert(http->storeEntry() == NULL);