spdy: push strategy move if-modified-since check from connection to ReferrerPushStrategy
This commit is contained in:
parent
a4fb0201f6
commit
f09eaee521
|
@ -104,16 +104,16 @@ public class ReferrerPushStrategy implements PushStrategy
|
|||
@Override
|
||||
public Set<String> apply(Stream stream, Headers requestHeaders, Headers responseHeaders)
|
||||
{
|
||||
Set<String> result = Collections.emptySet();
|
||||
Set<String> result = Collections.<String>emptySet();
|
||||
short version = stream.getSession().getVersion();
|
||||
String scheme = requestHeaders.get(HTTPSPDYHeader.SCHEME.name(version)).value();
|
||||
String host = requestHeaders.get(HTTPSPDYHeader.HOST.name(version)).value();
|
||||
String origin = new StringBuilder(scheme).append("://").append(host).toString();
|
||||
String url = requestHeaders.get(HTTPSPDYHeader.URI.name(version)).value();
|
||||
String absoluteURL = new StringBuilder(origin).append(url).toString();
|
||||
logger.debug("Applying push strategy for {}", absoluteURL);
|
||||
if (isValidMethod(requestHeaders.get(HTTPSPDYHeader.METHOD.name(version)).value()))
|
||||
if (!isIfModifiedSinceHeaderPresent(requestHeaders) && isValidMethod(requestHeaders.get(HTTPSPDYHeader.METHOD.name(version)).value()))
|
||||
{
|
||||
String scheme = requestHeaders.get(HTTPSPDYHeader.SCHEME.name(version)).value();
|
||||
String host = requestHeaders.get(HTTPSPDYHeader.HOST.name(version)).value();
|
||||
String origin = new StringBuilder(scheme).append("://").append(host).toString();
|
||||
String url = requestHeaders.get(HTTPSPDYHeader.URI.name(version)).value();
|
||||
String absoluteURL = new StringBuilder(origin).append(url).toString();
|
||||
logger.debug("Applying push strategy for {}", absoluteURL);
|
||||
if (isMainResource(url, responseHeaders))
|
||||
{
|
||||
result = pushResources(absoluteURL);
|
||||
|
@ -131,11 +131,16 @@ public class ReferrerPushStrategy implements PushStrategy
|
|||
result = pushResources(absoluteURL);
|
||||
}
|
||||
}
|
||||
logger.debug("Push resources for {}: {}", absoluteURL, result);
|
||||
}
|
||||
logger.debug("Push resources for {}: {}", absoluteURL, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean isIfModifiedSinceHeaderPresent(Headers headers)
|
||||
{
|
||||
return headers.get("if-modified-since") != null;
|
||||
}
|
||||
|
||||
private boolean isValidMethod(String method)
|
||||
{
|
||||
return "GET".equalsIgnoreCase(method);
|
||||
|
|
|
@ -403,7 +403,7 @@ public class ServerHTTPSPDYAsyncConnection extends AbstractHttpConnection implem
|
|||
if (!stream.isUnidirectional())
|
||||
stream.reply(replyInfo);
|
||||
if (replyInfo.getHeaders().get(HTTPSPDYHeader.STATUS.name(version)).value().startsWith("200") &&
|
||||
!stream.isClosed() && !isIfModifiedSinceHeaderPresent())
|
||||
!stream.isClosed())
|
||||
{
|
||||
// We have a 200 OK with some content to send
|
||||
|
||||
|
@ -438,11 +438,6 @@ public class ServerHTTPSPDYAsyncConnection extends AbstractHttpConnection implem
|
|||
}
|
||||
}
|
||||
|
||||
private boolean isIfModifiedSinceHeaderPresent()
|
||||
{
|
||||
return headers.get("if-modified-since") != null;
|
||||
}
|
||||
|
||||
private Buffer consumeContent(long maxIdleTime) throws IOException, InterruptedException
|
||||
{
|
||||
while (true)
|
||||
|
|
Loading…
Reference in New Issue