]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Remove sending chunked responses. 3.1 is still HTTP/1.0
authorAmos Jeffries <amosjeffries@squid-cache.org>
Fri, 3 Sep 2010 04:47:57 +0000 (22:47 -0600)
committerAmos Jeffries <amosjeffries@squid-cache.org>
Fri, 3 Sep 2010 04:47:57 +0000 (22:47 -0600)
Blocked by lack of HTTP/1.1 indicator on responses.
Better support is nearly ready but has not made this release.

src/client_side.cc
src/client_side.h
src/client_side_reply.cc
src/structs.h

index 8e20e90cd5f221ede0d4413ac55bd8a6e454342c..a03518a8e6e3322fd6e39211140735b497dc39c2 100644 (file)
@@ -855,7 +855,7 @@ ClientSocketContext::sendBody(HttpReply * rep, StoreIOBuffer bodyData)
 {
     assert(rep == NULL);
 
-    if (!multipartRangeRequest() && !http->request->flags.chunked_reply) {
+    if (!multipartRangeRequest()) {
         size_t length = lengthToSend(bodyData.range());
         noteSentBodyBytes (length);
         AsyncCall::Pointer call = commCbCall(33, 5, "clientWriteBodyComplete",
@@ -866,10 +866,7 @@ ClientSocketContext::sendBody(HttpReply * rep, StoreIOBuffer bodyData)
 
     MemBuf mb;
     mb.init();
-    if (multipartRangeRequest())
-        packRange(bodyData, &mb);
-    else
-        packChunk(bodyData, mb);
+    packRange(bodyData, &mb);
 
     if (mb.contentSize()) {
         /* write */
@@ -880,22 +877,6 @@ ClientSocketContext::sendBody(HttpReply * rep, StoreIOBuffer bodyData)
         writeComplete(fd(), NULL, 0, COMM_OK);
 }
 
-/**
- * Packs bodyData into mb using chunked encoding. Packs the last-chunk
- * if bodyData is empty.
- */
-void
-ClientSocketContext::packChunk(const StoreIOBuffer &bodyData, MemBuf &mb)
-{
-    const uint64_t length =
-        static_cast<uint64_t>(lengthToSend(bodyData.range()));
-    noteSentBodyBytes(length);
-
-    mb.Printf("%"PRIX64"\r\n", length);
-    mb.append(bodyData.data, length);
-    mb.Printf("\r\n");
-}
-
 /** put terminating boundary for multiparts */
 static void
 clientPackTermBound(String boundary, MemBuf * mb)
@@ -1262,15 +1243,13 @@ ClientSocketContext::sendStartOfMessage(HttpReply * rep, StoreIOBuffer bodyData)
 #endif
 
     if (bodyData.data && bodyData.length) {
-        if (multipartRangeRequest())
-            packRange(bodyData, mb);
-        else if (http->request->flags.chunked_reply) {
-            packChunk(bodyData, *mb);
-        } else {
+        if (!multipartRangeRequest()) {
             size_t length = lengthToSend(bodyData.range());
             noteSentBodyBytes (length);
 
             mb->append(bodyData.data, length);
+        } else {
+            packRange(bodyData, mb);
         }
     }
 
@@ -1319,11 +1298,7 @@ clientSocketRecipient(clientStreamNode * node, ClientHttpRequest * http,
         return;
     }
 
-    // After sending Transfer-Encoding: chunked (at least), always send
-    // the last-chunk if there was no error, ignoring responseFinishedOrFailed.
-    const bool mustSendLastChunk = http->request->flags.chunked_reply &&
-                                   !http->request->flags.stream_error && !context->startOfOutput();
-    if (responseFinishedOrFailed(rep, receivedData) && !mustSendLastChunk) {
+    if (responseFinishedOrFailed(rep, receivedData)) {
         context->writeComplete(fd, NULL, 0, COMM_OK);
         PROF_stop(clientSocketRecipient);
         return;
index acb13c353bddd32c9aa587a446ac2d516b18473f..0ec5ce5d5f158166d039f3f5476644154b41a5c0 100644 (file)
@@ -117,7 +117,6 @@ public:
 private:
     CBDATA_CLASS(ClientSocketContext);
     void prepareReply(HttpReply * rep);
-    void packChunk(const StoreIOBuffer &bodyData, MemBuf &mb);
     void packRange(StoreIOBuffer const &, MemBuf * mb);
     void deRegisterWithConn();
     void doClose();
index 9699b27a5acc03efc75953452791e00cd963d96f..359dd028eb457d5b76da78c66722f14a2591ab0a 100644 (file)
@@ -978,11 +978,6 @@ clientReplyContext::checkTransferDone()
     if (http->flags.done_copying)
         return 1;
 
-    if (http->request->flags.chunked_reply && !flags.complete) {
-        // last-chunk was not sent
-        return 0;
-    }
-
     /*
      * Handle STORE_OK objects.
      * objectLen(entry) will be set proprely.
@@ -1129,9 +1124,7 @@ clientReplyContext::replyStatus()
         debugs(88, 5, "clientReplyStatus: transfer is DONE");
         /* Ok we're finished, but how? */
 
-        const int64_t expectedBodySize =
-            http->storeEntry()->getReply()->bodySize(http->request->method);
-        if (!http->request->flags.proxy_keepalive && expectedBodySize < 0) {
+        if (http->storeEntry()->getReply()->bodySize(http->request->method) < 0) {
             debugs(88, 5, "clientReplyStatus: closing, content_length < 0");
             return STREAM_FAILED;
         }
@@ -1141,7 +1134,7 @@ clientReplyContext::replyStatus()
             return STREAM_FAILED;
         }
 
-        if (expectedBodySize >= 0 && !http->gotEnough()) {
+        if (!http->gotEnough()) {
             debugs(88, 5, "clientReplyStatus: client didn't get all it expected");
             return STREAM_UNPLANNED_COMPLETE;
         }
@@ -1377,9 +1370,6 @@ clientReplyContext::buildReplyHeader()
 
 #endif
 
-    const bool maySendChunkedReply = !request->multipartRangeRequest() &&
-                                     (request->http_ver >= HttpVersion(1, 1));
-
     /* Check whether we should send keep-alive */
     if (!Config.onoff.error_pconns && reply->sline.status >= 400 && !request->flags.must_keepalive) {
         debugs(33, 3, "clientBuildReplyHeader: Error, don't keep-alive");
@@ -1393,7 +1383,7 @@ clientReplyContext::buildReplyHeader()
     } else if (request->flags.connection_auth && !reply->keep_alive) {
         debugs(33, 2, "clientBuildReplyHeader: Connection oriented auth but server side non-persistent");
         request->flags.proxy_keepalive = 0;
-    } else if (reply->bodySize(request->method) < 0 && !maySendChunkedReply) {
+    } else if (reply->bodySize(request->method) < 0) {
         debugs(88, 3, "clientBuildReplyHeader: can't keep-alive, unknown body size" );
         request->flags.proxy_keepalive = 0;
     } else if (fdUsageHigh()&& !request->flags.must_keepalive) {
@@ -1401,15 +1391,6 @@ clientReplyContext::buildReplyHeader()
         request->flags.proxy_keepalive = 0;
     }
 
-    // Decide if we send chunked reply
-    if (maySendChunkedReply &&
-            request->flags.proxy_keepalive &&
-            reply->bodySize(request->method) < 0) {
-        debugs(88, 3, "clientBuildReplyHeader: chunked reply");
-        request->flags.chunked_reply = 1;
-        hdr->putStr(HDR_TRANSFER_ENCODING, "chunked");
-    }
-
     /* Append VIA */
     if (Config.onoff.via) {
         LOCAL_ARRAY(char, bbuf, MAX_URL + 32);
@@ -1743,7 +1724,6 @@ clientReplyContext::sendStreamError(StoreIOBuffer const &result)
     debugs(88, 5, "clientReplyContext::sendStreamError: A stream error has occured, marking as complete and sending no data.");
     StoreIOBuffer localTempBuffer;
     flags.complete = 1;
-    http->request->flags.stream_error = 1;
     localTempBuffer.flags.error = result.flags.error;
     clientStreamCallback((clientStreamNode*)http->client_stream.head->data, http, NULL,
                          localTempBuffer);
index 928037e8634aea3c20d5be52a88e48a840ac672c..493f822e050a4074a8af9c7bbde6da56513f7359 100644 (file)
@@ -1010,7 +1010,7 @@ struct _iostats {
 
 
 struct request_flags {
-    request_flags(): range(0),nocache(0),ims(0),auth(0),cachable(0),hierarchical(0),loopdetect(0),proxy_keepalive(0),proxying(0),refresh(0),redirected(0),need_validation(0),accelerated(0),ignore_cc(0),intercepted(0),spoof_client_ip(0),internal(0),internalclient(0),must_keepalive(0),chunked_reply(0),stream_error(0),destinationIPLookedUp_(0) {
+    request_flags(): range(0),nocache(0),ims(0),auth(0),cachable(0),hierarchical(0),loopdetect(0),proxy_keepalive(0),proxying(0),refresh(0),redirected(0),need_validation(0),accelerated(0),ignore_cc(0),intercepted(0),spoof_client_ip(0),internal(0),internalclient(0),must_keepalive(0),destinationIPLookedUp_(0) {
 #if HTTP_VIOLATIONS
         nocache_hack = 0;
 #endif
@@ -1048,8 +1048,6 @@ unsigned int proxying:
     unsigned int pinned:1;      /* Request sent on a pinned connection */
     unsigned int auth_sent:1;   /* Authentication forwarded */
     unsigned int no_direct:1;  /* Deny direct forwarding unless overriden by always_direct. Used in accelerator mode */
-    unsigned int chunked_reply:1; /**< Reply with chunked transfer encoding */
-    unsigned int stream_error:1; /**< Whether stream error has occured */
 
     // When adding new flags, please update cloneAdaptationImmune() as needed.