Ignore:
Timestamp:
Jul 13, 2017, 9:01:05 AM (22 months ago)
Author:
Juanma
Message:

Initial release

File:
1 edited

Legend:

Unmodified
Added
Removed
  • squid-ssl/trunk/fuentes/src/client_side_reply.cc

    r5495 r5496  
    475475    }
    476476
    477     // The previously identified hit suddenly became unsharable!
    478     // This is common for collapsed forwarding slaves but might also
    479     // happen to regular hits because we are called asynchronously.
    480     if (EBIT_TEST(e->flags, KEY_PRIVATE)) {
    481         debugs(88, 3, "unsharable " << *e << ". MISS");
    482         http->logType = LOG_TCP_MISS;
    483         processMiss();
    484         return;
    485     }
    486 
    487477    if (result.length == 0) {
    488478        debugs(88, 5, "store IO buffer has no content. MISS");
     
    556546        http->logType = LOG_TCP_NEGATIVE_HIT;
    557547        sendMoreData(result);
    558         return;
    559548    } else if (blockedHit()) {
    560549        debugs(88, 5, "send_hit forces a MISS");
     
    608597            processMiss();
    609598        }
    610         return;
    611599    } else if (r->conditional()) {
    612600        debugs(88, 5, "conditional HIT");
    613         if (processConditional(result))
    614             return;
    615     }
    616 
    617     /*
    618      * plain ol' cache hit
    619      */
    620     debugs(88, 5, "plain old HIT");
     601        processConditional(result);
     602    } else {
     603        /*
     604         * plain ol' cache hit
     605         */
     606        debugs(88, 5, "plain old HIT");
    621607
    622608#if USE_DELAY_POOLS
    623     if (e->store_status != STORE_OK)
    624         http->logType = LOG_TCP_MISS;
    625     else
    626 #endif
    627         if (e->mem_status == IN_MEMORY)
    628             http->logType = LOG_TCP_MEM_HIT;
    629         else if (Config.onoff.offline)
    630             http->logType = LOG_TCP_OFFLINE_HIT;
    631 
    632     sendMoreData(result);
     609        if (e->store_status != STORE_OK)
     610            http->logType = LOG_TCP_MISS;
     611        else
     612#endif
     613            if (e->mem_status == IN_MEMORY)
     614                http->logType = LOG_TCP_MEM_HIT;
     615            else if (Config.onoff.offline)
     616                http->logType = LOG_TCP_OFFLINE_HIT;
     617
     618        sendMoreData(result);
     619    }
    633620}
    634621
     
    724711
    725712/// process conditional request from client
    726 bool
     713void
    727714clientReplyContext::processConditional(StoreIOBuffer &result)
    728715{
     
    730717
    731718    if (e->getReply()->sline.status() != Http::scOkay) {
    732         debugs(88, 4, "Reply code " << e->getReply()->sline.status() << " != 200");
     719        debugs(88, 4, "clientReplyContext::processConditional: Reply code " <<
     720               e->getReply()->sline.status() << " != 200");
    733721        http->logType = LOG_TCP_MISS;
    734722        processMiss();
    735         return true;
     723        return;
    736724    }
    737725
     
    741729        // RFC 2616: reply with 412 Precondition Failed if If-Match did not match
    742730        sendPreconditionFailedError();
    743         return true;
    744     }
    745 
     731        return;
     732    }
     733
     734    bool matchedIfNoneMatch = false;
    746735    if (r.header.has(HDR_IF_NONE_MATCH)) {
    747         // RFC 7232: If-None-Match recipient MUST ignore IMS
    748         r.flags.ims = false;
    749         r.ims = -1;
    750         r.imslen = 0;
    751         r.header.delById(HDR_IF_MODIFIED_SINCE);
    752 
    753         if (e->hasIfNoneMatchEtag(r)) {
     736        if (!e->hasIfNoneMatchEtag(r)) {
     737            // RFC 2616: ignore IMS if If-None-Match did not match
     738            r.flags.ims = false;
     739            r.ims = -1;
     740            r.imslen = 0;
     741            r.header.delById(HDR_IF_MODIFIED_SINCE);
     742            http->logType = LOG_TCP_MISS;
     743            sendMoreData(result);
     744            return;
     745        }
     746
     747        if (!r.flags.ims) {
     748            // RFC 2616: if If-None-Match matched and there is no IMS,
     749            // reply with 304 Not Modified or 412 Precondition Failed
    754750            sendNotModifiedOrPreconditionFailedError();
    755             return true;
    756         }
    757 
    758         // None-Match is true (no ETag matched); treat as an unconditional hit
    759         return false;
     751            return;
     752        }
     753
     754        // otherwise check IMS below to decide if we reply with 304 or 412
     755        matchedIfNoneMatch = true;
    760756    }
    761757
     
    763759        // handle If-Modified-Since requests from the client
    764760        if (e->modifiedSince(&r)) {
    765             // Modified-Since is true; treat as an unconditional hit
    766             return false;
    767 
    768         } else {
    769             // otherwise reply with 304 Not Modified
    770             sendNotModified();
    771         }
    772         return true;
    773     }
    774 
    775     return false;
     761            http->logType = LOG_TCP_IMS_HIT;
     762            sendMoreData(result);
     763            return;
     764        }
     765
     766        if (matchedIfNoneMatch) {
     767            // If-None-Match matched, reply with 304 Not Modified or
     768            // 412 Precondition Failed
     769            sendNotModifiedOrPreconditionFailedError();
     770            return;
     771        }
     772
     773        // otherwise reply with 304 Not Modified
     774        sendNotModified();
     775    }
    776776}
    777777
     
    19201920    const time_t timestamp = e->timestamp;
    19211921    HttpReply *const temprep = e->getReply()->make304();
    1922     // log as TCP_INM_HIT if code 304 generated for
    1923     // If-None-Match request
    1924     if (!http->request->flags.ims)
    1925         http->logType = LOG_TCP_INM_HIT;
    1926     else
    1927         http->logType = LOG_TCP_IMS_HIT;
     1922    http->logType = LOG_TCP_IMS_HIT;
    19281923    removeClientStoreReference(&sc, http);
    19291924    createStoreEntry(http->request->method, RequestFlags());
Note: See TracChangeset for help on using the changeset viewer.