]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/client_side_request.cc
Maintenance: Removed most NULLs using modernize-use-nullptr (#1075)
[thirdparty/squid.git] / src / client_side_request.cc
index c2cc0baf6bc88dd534b0a6808e38529ceb48e61c..5eed9f1c54088596b8bdea2eb117def045e1758e 100644 (file)
@@ -139,7 +139,7 @@ ClientHttpRequest::ClientHttpRequest(ConnStateData * aConn) :
         al->updateError(aConn->bareError);
 
 #if USE_OPENSSL
-        if (aConn->clientConnection != NULL && aConn->clientConnection->isOpen()) {
+        if (aConn->clientConnection != nullptr && aConn->clientConnection->isOpen()) {
             if (auto ssl = fd_table[aConn->clientConnection->fd].ssl.get())
                 al->cache.sslClientCert.resetWithoutLocking(SSL_get_peer_certificate(ssl));
         }
@@ -243,7 +243,7 @@ ClientHttpRequest::~ClientHttpRequest()
 
     logRequest();
 
-    loggingEntry(NULL);
+    loggingEntry(nullptr);
 
     if (request)
         checkFailureRatio(request->error.category, al->hier.code);
@@ -253,7 +253,7 @@ ClientHttpRequest::~ClientHttpRequest()
 #if USE_ADAPTATION
     announceInitiatorAbort(virginHeadSource);
 
-    if (adaptedBodySource != NULL)
+    if (adaptedBodySource != nullptr)
         stopConsumingFrom(adaptedBodySource);
 #endif
 
@@ -281,10 +281,10 @@ clientBeginRequest(const HttpRequestMethod& method, char const *url, CSCB * stre
                    char *tailbuf, size_t taillen, const MasterXaction::Pointer &mx)
 {
     size_t url_sz;
-    ClientHttpRequest *http = new ClientHttpRequest(NULL);
+    ClientHttpRequest *http = new ClientHttpRequest(nullptr);
     HttpRequest *request;
     StoreIOBuffer tempBuffer;
-    if (http->al != NULL)
+    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;
@@ -369,7 +369,7 @@ ClientRequestContext::httpStateIsValid()
     if (cbdataReferenceValid(http_))
         return true;
 
-    http = NULL;
+    http = nullptr;
 
     cbdataReferenceDone(http_);
 
@@ -527,9 +527,9 @@ ClientRequestContext::hostHeaderVerifyFailed(const char *A, const char *B)
                                 nullptr,
                                 http->getConn(),
                                 http->request,
-                                NULL,
+                                nullptr,
 #if USE_AUTH
-                                http->getConn() != NULL && http->getConn()->getAuth() != NULL ?
+                                http->getConn() != nullptr && http->getConn()->getAuth() != nullptr ?
                                 http->getConn()->getAuth() : http->request->auth_user_request);
 #else
                                 NULL);
@@ -561,14 +561,14 @@ ClientRequestContext::hostHeaderVerify()
     }
 
     // Locate if there is a port attached, strip ready for IP lookup
-    char *portStr = NULL;
+    char *portStr = nullptr;
     char *hostB = xstrdup(host);
     host = hostB;
     if (host[0] == '[') {
         // IPv6 literal.
         portStr = strchr(hostB, ']');
         if (portStr && *(++portStr) != ':') {
-            portStr = NULL;
+            portStr = nullptr;
         }
     } else {
         // Domain or IPv4 literal with port
@@ -579,12 +579,12 @@ ClientRequestContext::hostHeaderVerify()
     if (portStr) {
         *portStr = '\0'; // strip the ':'
         if (*(++portStr) != '\0') {
-            char *end = NULL;
+            char *end = nullptr;
             int64_t ret = strtoll(portStr, &end, 10);
             if (end == portStr || *end != '\0' || ret < 1 || ret > 0xFFFF) {
                 // invalid port details. Replace the ':'
                 *(--portStr) = ':';
-                portStr = NULL;
+                portStr = nullptr;
             } else
                 port = (ret & 0xFFFF);
         }
@@ -695,7 +695,7 @@ clientAccessCheckDoneWrapper(Acl::Answer answer, void *data)
 void
 ClientRequestContext::clientAccessCheckDone(const Acl::Answer &answer)
 {
-    acl_checklist = NULL;
+    acl_checklist = nullptr;
     err_type page_id;
     Http::StatusCode status;
     debugs(85, 2, "The request " << http->request->method << ' ' <<
@@ -704,9 +704,9 @@ ClientRequestContext::clientAccessCheckDone(const Acl::Answer &answer)
 
 #if USE_AUTH
     char const *proxy_auth_msg = "<null>";
-    if (http->getConn() != NULL && http->getConn()->getAuth() != NULL)
+    if (http->getConn() != nullptr && http->getConn()->getAuth() != nullptr)
         proxy_auth_msg = http->getConn()->getAuth()->denyMessage("<null>");
-    else if (http->request->auth_user_request != NULL)
+    else if (http->request->auth_user_request != nullptr)
         proxy_auth_msg = http->request->auth_user_request->denyMessage("<null>");
 #endif
 
@@ -762,7 +762,7 @@ ClientRequestContext::clientAccessCheckDone(const Acl::Answer &answer)
 
 #if USE_AUTH
         error->auth_user_request =
-            http->getConn() != NULL && http->getConn()->getAuth() != NULL ?
+            http->getConn() != nullptr && http->getConn()->getAuth() != nullptr ?
             http->getConn()->getAuth() : http->request->auth_user_request;
 #endif
 
@@ -783,8 +783,8 @@ ClientHttpRequest::noteAdaptationAclCheckDone(Adaptation::ServiceGroupPointer g)
 
 #if ICAP_CLIENT
     Adaptation::Icap::History::Pointer ih = request->icapHistory();
-    if (ih != NULL) {
-        if (getConn() != NULL && getConn()->clientConnection != NULL) {
+    if (ih != nullptr) {
+        if (getConn() != nullptr && getConn()->clientConnection != nullptr) {
             ih->rfc931 = getConn()->clientConnection->rfc931;
 #if USE_OPENSSL
             if (getConn()->clientConnection->isOpen()) {
@@ -813,7 +813,7 @@ clientRedirectAccessCheckDone(Acl::Answer answer, void *data)
 {
     ClientRequestContext *context = (ClientRequestContext *)data;
     ClientHttpRequest *http = context->http;
-    context->acl_checklist = NULL;
+    context->acl_checklist = nullptr;
 
     if (answer.allowed())
         redirectStart(http, clientRedirectDoneWrapper, context);
@@ -844,7 +844,7 @@ clientStoreIdAccessCheckDone(Acl::Answer answer, void *data)
 {
     ClientRequestContext *context = static_cast<ClientRequestContext *>(data);
     ClientHttpRequest *http = context->http;
-    context->acl_checklist = NULL;
+    context->acl_checklist = nullptr;
 
     if (answer.allowed())
         storeIdStart(http, clientStoreIdDoneWrapper, context);
@@ -1184,7 +1184,7 @@ ClientRequestContext::clientRedirectDone(const Helper::Reply &reply)
         const char *statusNote = reply.notes.findFirst("status");
         const char *urlNote = reply.notes.findFirst("url");
 
-        if (urlNote != NULL) {
+        if (urlNote != nullptr) {
             // HTTP protocol redirect to be done.
 
             // TODO: change default redirect status for appropriate requests
@@ -1193,7 +1193,7 @@ ClientRequestContext::clientRedirectDone(const Helper::Reply &reply)
             // HTTP/1.1 client contacting reverse-proxy should get 307 (Http::scTemporaryRedirect)
             // HTTP/1.1 client being diverted by forward-proxy should get 303 (Http::scSeeOther)
             Http::StatusCode status = Http::scFound;
-            if (statusNote != NULL) {
+            if (statusNote != nullptr) {
                 const char * result = statusNote;
                 status = static_cast<Http::StatusCode>(atoi(result));
             }
@@ -1214,7 +1214,7 @@ ClientRequestContext::clientRedirectDone(const Helper::Reply &reply)
             urlNote = reply.notes.findFirst("rewrite-url");
 
             // prevent broken helpers causing too much damage. If old URL == new URL skip the re-write.
-            if (urlNote != NULL && strcmp(urlNote, http->uri)) {
+            if (urlNote != nullptr && strcmp(urlNote, http->uri)) {
                 AnyP::Uri tmpUrl;
                 if (tmpUrl.parse(old_request->method, SBuf(urlNote))) {
                     HttpRequest *new_request = old_request->clone();
@@ -1225,8 +1225,8 @@ ClientRequestContext::clientRedirectDone(const Helper::Reply &reply)
                     new_request->flags.redirected = true;
 
                     // unlink bodypipe from the old request. Not needed there any longer.
-                    if (old_request->body_pipe != NULL) {
-                        old_request->body_pipe = NULL;
+                    if (old_request->body_pipe != nullptr) {
+                        old_request->body_pipe = nullptr;
                         debugs(61,2, "URL-rewriter diverts body_pipe " << new_request->body_pipe <<
                                " from request " << old_request << " to " << new_request);
                     }
@@ -1245,7 +1245,7 @@ ClientRequestContext::clientRedirectDone(const Helper::Reply &reply)
 
     /* XXX PIPELINE: This is inaccurate during pipelining */
 
-    if (http->getConn() != NULL && Comm::IsConnOpen(http->getConn()->clientConnection))
+    if (http->getConn() != nullptr && Comm::IsConnOpen(http->getConn()->clientConnection))
         fd_note(http->getConn()->clientConnection->fd, http->uri);
 
     assert(http->uri);
@@ -1293,7 +1293,7 @@ ClientRequestContext::clientStoreIdDone(const Helper::Reply &reply)
         const char *urlNote = reply.notes.findFirst("store-id");
 
         // prevent broken helpers causing too much damage. If old URL == new URL skip the re-write.
-        if (urlNote != NULL && strcmp(urlNote, http->uri) ) {
+        if (urlNote != nullptr && strcmp(urlNote, http->uri) ) {
             // Debug section required for some very specific cases.
             debugs(85, 9, "Setting storeID with: " << urlNote );
             http->request->store_id = urlNote;
@@ -1335,7 +1335,7 @@ checkNoCacheDoneWrapper(Acl::Answer answer, void *data)
 void
 ClientRequestContext::checkNoCacheDone(const Acl::Answer &answer)
 {
-    acl_checklist = NULL;
+    acl_checklist = nullptr;
     if (answer.denied()) {
         http->request->flags.noCache = true; // do not read reply from cache
         http->request->flags.cachable = false; // do not store reply into cache
@@ -1531,7 +1531,7 @@ ClientHttpRequest::sslBumpEstablish(Comm::Flag errflag)
 
 #if USE_AUTH
     // Preserve authentication info for the ssl-bumped request
-    if (request->auth_user_request != NULL)
+    if (request->auth_user_request != nullptr)
         getConn()->setAuth(request->auth_user_request, "SSL-bumped CONNECT");
 #endif
 
@@ -1713,7 +1713,7 @@ ClientHttpRequest::doCallouts()
             calloutContext->adaptation_acl_check_done = true;
             if (Adaptation::AccessCheck::Start(
                         Adaptation::methodReqmod, Adaptation::pointPreCache,
-                        request, NULL, calloutContext->http->al, this))
+                        request, nullptr, calloutContext->http->al, this))
                 return; // will call callback
         }
 #endif
@@ -1812,7 +1812,7 @@ ClientHttpRequest::doCallouts()
             // set final error but delay sending until we bump
             Ssl::ServerBump *srvBump = new Ssl::ServerBump(this, e, Ssl::bumpClientFirst);
             errorAppendEntry(e, calloutContext->error);
-            calloutContext->error = NULL;
+            calloutContext->error = nullptr;
             getConn()->setServerBump(srvBump);
             e->unlock("ClientHttpRequest::doCallouts+sslBumpNeeded");
         } else
@@ -1824,7 +1824,7 @@ ClientHttpRequest::doCallouts()
             assert (repContext);
             repContext->setReplyToStoreEntry(e, "immediate SslBump error");
             errorAppendEntry(e, calloutContext->error);
-            calloutContext->error = NULL;
+            calloutContext->error = nullptr;
             if (calloutContext->readNextRequest && getConn())
                 getConn()->flags.readMore = true; // resume any pipeline reads.
             node = (clientStreamNode *)client_stream.tail->data;
@@ -1836,7 +1836,7 @@ ClientHttpRequest::doCallouts()
 
     cbdataReferenceDone(calloutContext->http);
     delete calloutContext;
-    calloutContext = NULL;
+    calloutContext = nullptr;
 #if HEADERS_LOG
 
     headersLog(0, 1, request->method, request);
@@ -1847,7 +1847,7 @@ ClientHttpRequest::doCallouts()
 
 #if ICAP_CLIENT
     Adaptation::Icap::History::Pointer ih = request->icapHistory();
-    if (ih != NULL)
+    if (ih != nullptr)
         ih->logType = loggingTags();
 #endif
 }
@@ -1932,7 +1932,7 @@ ClientHttpRequest::startAdaptation(const Adaptation::ServiceGroupPointer &g)
     assert(!virginHeadSource);
     assert(!adaptedBodySource);
     virginHeadSource = initiateAdaptation(
-                           new Adaptation::Iterator(request, NULL, al, g));
+                           new Adaptation::Iterator(request, nullptr, al, g));
 
     // we could try to guess whether we can bypass this adaptation
     // initiation failure, but it should not really happen
@@ -1978,7 +1978,7 @@ ClientHttpRequest::handleAdaptedHeader(Http::Message *msg)
         debugs(85,3, "REQMOD reply is HTTP reply");
 
         // subscribe to receive reply body
-        if (new_rep->body_pipe != NULL) {
+        if (new_rep->body_pipe != nullptr) {
             adaptedBodySource = new_rep->body_pipe;
             int consumer_ok = adaptedBodySource->setConsumerIfNotLate(this);
             assert(consumer_ok);
@@ -2016,7 +2016,7 @@ ClientHttpRequest::handleAdaptationBlock(const Adaptation::Answer &answer)
     AclMatchedName = answer.ruleId.termedBuf();
     assert(calloutContext);
     calloutContext->clientAccessCheckDone(ACCESS_DENIED);
-    AclMatchedName = NULL;
+    AclMatchedName = nullptr;
 }
 
 void
@@ -2032,7 +2032,7 @@ void
 ClientHttpRequest::noteMoreBodyDataAvailable(BodyPipe::Pointer)
 {
     assert(request_satisfaction_mode);
-    assert(adaptedBodySource != NULL);
+    assert(adaptedBodySource != nullptr);
 
     if (size_t contentSize = adaptedBodySource->buf().contentSize()) {
         const size_t spaceAvailable = storeEntry()->bytesWanted(Range<size_t>(0,contentSize));
@@ -2075,7 +2075,7 @@ ClientHttpRequest::noteBodyProductionEnded(BodyPipe::Pointer)
     receivedWholeAdaptedReply = true;
 
     // should we end request satisfaction now?
-    if (adaptedBodySource != NULL && adaptedBodySource->exhausted())
+    if (adaptedBodySource != nullptr && adaptedBodySource->exhausted())
         endRequestSatisfaction();
 }
 
@@ -2122,7 +2122,7 @@ ClientHttpRequest::handleAdaptationFailure(const ErrorDetail::Pointer &errDetail
     debugs(85,3, "handleAdaptationFailure(" << bypassable << ")");
 
     const bool usedStore = storeEntry() && !storeEntry()->isEmpty();
-    const bool usedPipe = request->body_pipe != NULL &&
+    const bool usedPipe = request->body_pipe != nullptr &&
                           request->body_pipe->consumedSize() > 0;
 
     if (bypassable && !usedStore && !usedPipe) {
@@ -2174,11 +2174,11 @@ ClientHttpRequest::calloutsError(const err_type error, const ErrorDetail::Pointe
                                 nullptr, c, request, al);
 #if USE_AUTH
         calloutContext->error->auth_user_request =
-            c != NULL && c->getAuth() != NULL ? c->getAuth() : request->auth_user_request;
+            c != nullptr && c->getAuth() != nullptr ? c->getAuth() : request->auth_user_request;
 #endif
         calloutContext->error->detailError(errDetail);
         calloutContext->readNextRequest = true;
-        if (c != NULL)
+        if (c != nullptr)
             c->expectNoForwarding();
     }
     //else if(calloutContext == NULL) is it possible?