jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From FSchumacher <...@git.apache.org>
Subject [GitHub] jmeter pull request #298: Vary header cache
Date Tue, 20 Jun 2017 17:31:52 GMT
Github user FSchumacher commented on a diff in the pull request:

    https://github.com/apache/jmeter/pull/298#discussion_r123043201
  
    --- Diff: src/protocol/http/org/apache/jmeter/protocol/http/control/CacheManager.java
---
    @@ -127,19 +163,28 @@ public Date getExpires() {
          * @param res result
          */
         public void saveDetails(URLConnection conn, HTTPSampleResult res){
    -        if (isCacheable(res) && !hasVaryHeader(conn)){
    +        if (isCacheable(res)){
                 String lastModified = conn.getHeaderField(HTTPConstants.LAST_MODIFIED);
                 String expires = conn.getHeaderField(HTTPConstants.EXPIRES);
                 String etag = conn.getHeaderField(HTTPConstants.ETAG);
                 String url = conn.getURL().toString();
                 String cacheControl = conn.getHeaderField(HTTPConstants.CACHE_CONTROL);
                 String date = conn.getHeaderField(HTTPConstants.DATE);
    -            setCache(lastModified, cacheControl, expires, etag, url, date);
    +            setCache(lastModified, cacheControl, expires, etag, url, date, getVaryHeader(conn.getHeaderField(HTTPConstants.VARY),
res.getRequestHeaders()));
             }
         }
     
    -    private boolean hasVaryHeader(URLConnection conn) {
    -        return conn.getHeaderField(HTTPConstants.VARY) != null;
    +    private Pair<String, String> getVaryHeader(String headerName, String reqHeaders)
{
    +        if (headerName == null) {
    +            return null;
    +        }
    +        for (String headerLine: reqHeaders.split("\n")) {
    +            if (headerLine.startsWith(headerName + ": ")) {
    --- End diff --
    
    I am thinking of splitting the `headerLine`, so that I can easier compare the `headerName`
ignoring the case.
    
    And as undera pointed out, a vary header can have multiple values (separated by comma),
so this logic will have to be changed anyway.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message