Github user vlsi commented on a diff in the pull request:
https://github.com/apache/jmeter/pull/298#discussion_r122906273
--- 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 --
Please move string concatenation out of a loop
---
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 [email protected] or file a JIRA ticket
with INFRA.
---