From 0e4873fab958b5b0c17c9a381c5acd87db66c1da Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Tue, 8 Oct 2024 16:03:03 +0000 Subject: [PATCH] Maintenance: Remove unused clientBeginRequest() (#1910) This ESI-only function became unused since recent commit 5eb89ef3. It has enough problematic code and comments to justify dedicated removal. --- .../05_TypicalRequestFlow.dox | 3 +- src/Downloader.cc | 1 + src/client_side_reply.cc | 1 + src/client_side_request.cc | 95 ------------------- src/client_side_request.h | 4 - src/http/Stream.cc | 1 + src/redirect.cc | 1 + src/servers/Http1Server.cc | 1 + 8 files changed, 6 insertions(+), 101 deletions(-) diff --git a/doc/Programming-Guide/05_TypicalRequestFlow.dox b/doc/Programming-Guide/05_TypicalRequestFlow.dox index 1a9e9344129..c8b346908c7 100644 --- a/doc/Programming-Guide/05_TypicalRequestFlow.dox +++ b/doc/Programming-Guide/05_TypicalRequestFlow.dox @@ -11,8 +11,7 @@ \par \li A client connection is accepted by the client-side socket - support and parsed, or is directly created via - clientBeginRequest(). + support and parsed. \li The access controls are checked. The client-side-request builds an ACL state data structure and registers a callback function diff --git a/src/Downloader.cc b/src/Downloader.cc index 022381ae3cd..b2fbec21660 100644 --- a/src/Downloader.cc +++ b/src/Downloader.cc @@ -12,6 +12,7 @@ #include "client_side_reply.h" #include "client_side_request.h" #include "ClientRequestContext.h" +#include "clientStream.h" #include "Downloader.h" #include "fatal.h" #include "http/one/RequestParser.h" diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index 620c83d8f2b..66c53916111 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -13,6 +13,7 @@ #include "acl/Gadgets.h" #include "anyp/PortCfg.h" #include "client_side_reply.h" +#include "clientStream.h" #include "errorpage.h" #include "ETag.h" #include "fd.h" diff --git a/src/client_side_request.cc b/src/client_side_request.cc index c7778253e91..b9a6d9d2bc5 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -268,101 +268,6 @@ ClientHttpRequest::~ClientHttpRequest() dlinkDelete(&active, &ClientActiveRequests); } -/** - * Create a request and kick it off - * - * \retval 0 success - * \retval -1 failure - * - * TODO: Pass in the buffers to be used in the initial Read request, as they are - * determined by the user - */ -int -clientBeginRequest(const HttpRequestMethod &method, char const *url, CSCB *streamcallback, - CSD *streamdetach, const ClientStreamData &streamdata, const HttpHeader *header, - char *tailbuf, size_t taillen, const MasterXaction::Pointer &mx) -{ - size_t url_sz; - ClientHttpRequest *http = new ClientHttpRequest(nullptr); - HttpRequest *request; - StoreIOBuffer tempBuffer; - if (http->al != nullptr) - http->al->cache.start_time = current_time; - /* this is only used to adjust the connection offset in client_side.c */ - http->req_sz = 0; - tempBuffer.length = taillen; - tempBuffer.data = tailbuf; - /* client stream setup */ - clientStreamInit(&http->client_stream, clientGetMoreData, clientReplyDetach, - clientReplyStatus, new clientReplyContext(http), streamcallback, - streamdetach, streamdata, tempBuffer); - /* make it visible in the 'current acctive requests list' */ - /* Set flags */ - /* internal requests only makes sense in an - * accelerator today. TODO: accept flags ? */ - http->flags.accel = true; - /* allow size for url rewriting */ - url_sz = strlen(url) + Config.appendDomainLen + 5; - http->uri = (char *)xcalloc(url_sz, 1); - strcpy(http->uri, url); // XXX: polluting http->uri before parser validation - - request = HttpRequest::FromUrlXXX(http->uri, mx, method); - if (!request) { - debugs(85, 5, "Invalid URL: " << http->uri); - return -1; - } - - /* - * now update the headers in request with our supplied headers. - * HttpRequest::FromUrl() should return a blank header set, but - * we use Update to be sure of correctness. - */ - if (header) - request->header.update(header); - - /* http struct now ready */ - - /* - * build new header list *? TODO - */ - request->flags.accelerated = http->flags.accel; - - /* this is an internally created - * request, not subject to acceleration - * target overrides */ - // TODO: detect and handle internal requests of internal objects? - - /* Internally created requests cannot have bodies today */ - request->content_length = 0; - - request->client_addr.setNoAddr(); - -#if FOLLOW_X_FORWARDED_FOR - request->indirect_client_addr.setNoAddr(); -#endif /* FOLLOW_X_FORWARDED_FOR */ - - request->my_addr.setNoAddr(); /* undefined for internal requests */ - - request->my_addr.port(0); - - request->http_ver = Http::ProtocolVersion(); - - http->initRequest(request); - - /* optional - skip the access check ? */ - http->calloutContext = new ClientRequestContext(http); - - http->calloutContext->http_access_done = false; - - http->calloutContext->redirect_done = true; - - http->calloutContext->no_cache_done = true; - - http->doCallouts(); - - return 0; -} - bool ClientRequestContext::httpStateIsValid() { diff --git a/src/client_side_request.h b/src/client_side_request.h index bff45673b39..6a93b87ddd6 100644 --- a/src/client_side_request.h +++ b/src/client_side_request.h @@ -12,7 +12,6 @@ #include "AccessLogEntry.h" #include "acl/FilledChecklist.h" #include "client_side.h" -#include "clientStream.h" #include "http/forward.h" #include "HttpHeaderRange.h" #include "log/forward.h" @@ -28,9 +27,6 @@ class ClientRequestContext; class ConnStateData; class MemObject; -/* client_side_request.c - client side request related routines (pure logic) */ -int clientBeginRequest(const HttpRequestMethod &, char const *, CSCB *, CSD *, const ClientStreamData &, const HttpHeader *, char *, size_t, const MasterXactionPointer &); - class ClientHttpRequest #if USE_ADAPTATION : public Adaptation::Initiator, // to start adaptation transactions diff --git a/src/http/Stream.cc b/src/http/Stream.cc index 1538d69fe2c..83f8329d5af 100644 --- a/src/http/Stream.cc +++ b/src/http/Stream.cc @@ -8,6 +8,7 @@ #include "squid.h" #include "client_side_request.h" +#include "clientStream.h" #include "http/Stream.h" #include "HttpHdrContRange.h" #include "HttpHeaderTools.h" diff --git a/src/redirect.cc b/src/redirect.cc index ddf79018234..816aab0ffba 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -14,6 +14,7 @@ #include "client_side.h" #include "client_side_reply.h" #include "client_side_request.h" +#include "clientStream.h" #include "comm/Connection.h" #include "fde.h" #include "format/Format.h" diff --git a/src/servers/Http1Server.cc b/src/servers/Http1Server.cc index 05151a339ce..24c1974ba3f 100644 --- a/src/servers/Http1Server.cc +++ b/src/servers/Http1Server.cc @@ -13,6 +13,7 @@ #include "client_side.h" #include "client_side_reply.h" #include "client_side_request.h" +#include "clientStream.h" #include "comm/Write.h" #include "http/one/RequestParser.h" #include "http/Stream.h"