aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Becker2013-08-30 10:07:24 (EDT)
committerThomas Becker2013-08-30 11:15:14 (EDT)
commitfcdea1d4b43a3d96e48faa2b1a54c74ddaf36cbe (patch)
tree0aba3c2e11aaad69a02526676c51b1b452c81553
parent9565d2647e1da8a6e327936b9048326de9d16597 (diff)
downloadorg.eclipse.jetty.project-fcdea1d4b43a3d96e48faa2b1a54c74ddaf36cbe.zip
org.eclipse.jetty.project-fcdea1d4b43a3d96e48faa2b1a54c74ddaf36cbe.tar.gz
org.eclipse.jetty.project-fcdea1d4b43a3d96e48faa2b1a54c74ddaf36cbe.tar.bz2
416242 respect persistence headers in ProxyHTTPSPDYConnection
-rw-r--r--jetty-spdy/spdy-http-server/src/main/java/org/eclipse/jetty/spdy/server/proxy/ProxyHTTPSPDYConnection.java48
1 files changed, 47 insertions, 1 deletions
diff --git a/jetty-spdy/spdy-http-server/src/main/java/org/eclipse/jetty/spdy/server/proxy/ProxyHTTPSPDYConnection.java b/jetty-spdy/spdy-http-server/src/main/java/org/eclipse/jetty/spdy/server/proxy/ProxyHTTPSPDYConnection.java
index 8b0d92a..9a269fa 100644
--- a/jetty-spdy/spdy-http-server/src/main/java/org/eclipse/jetty/spdy/server/proxy/ProxyHTTPSPDYConnection.java
+++ b/jetty-spdy/spdy-http-server/src/main/java/org/eclipse/jetty/spdy/server/proxy/ProxyHTTPSPDYConnection.java
@@ -26,6 +26,7 @@ import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpFields;
import org.eclipse.jetty.http.HttpGenerator;
import org.eclipse.jetty.http.HttpHeader;
+import org.eclipse.jetty.http.HttpHeaderValue;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpParser;
import org.eclipse.jetty.http.HttpVersion;
@@ -143,10 +144,16 @@ public class ProxyHTTPSPDYConnection extends HttpConnection implements HttpParse
{
stream.getStreamFrameListener().onData(stream, toDataInfo(content, true));
}
+ return false;
+ }
+
+ @Override
+ public void completed()
+ {
headers.clear();
stream = null;
content = null;
- return false;
+ super.completed();
}
@Override
@@ -235,6 +242,8 @@ public class ProxyHTTPSPDYConnection extends HttpConnection implements HttpParse
{
Fields headers = new Fields(replyInfo.getHeaders(), false);
+ addPersistenceHeader(headers);
+
headers.remove(HTTPSPDYHeader.SCHEME.name(version));
String status = headers.remove(HTTPSPDYHeader.STATUS.name(version)).value();
@@ -314,6 +323,43 @@ public class ProxyHTTPSPDYConnection extends HttpConnection implements HttpParse
}
}
+ private void addPersistenceHeader(Fields headersToAddTo)
+ {
+ HttpVersion httpVersion = HttpVersion.fromString(headers.get("version").value());
+ boolean persistent = false;
+ switch (httpVersion)
+ {
+ case HTTP_1_0:
+ {
+ Fields.Field keepAliveHeader = headers.get(HttpHeader.KEEP_ALIVE.asString());
+ if(keepAliveHeader!=null)
+ persistent = HttpHeaderValue.KEEP_ALIVE.asString().equals(keepAliveHeader.value());
+ if (!persistent)
+ persistent = HttpMethod.CONNECT.is(headers.get("method").value());
+ if (persistent)
+ headersToAddTo.add(HttpHeader.CONNECTION.asString(), HttpHeaderValue.KEEP_ALIVE.asString());
+ break;
+ }
+ case HTTP_1_1:
+ {
+ Fields.Field connectionHeader = headers.get(HttpHeader.CONNECTION.asString());
+ if(connectionHeader != null)
+ persistent = !HttpHeaderValue.CLOSE.asString().equals(connectionHeader.value());
+ else
+ persistent = true;
+ if (!persistent)
+ persistent = HttpMethod.CONNECT.is(headers.get("method").value());
+ if (!persistent)
+ headersToAddTo.add(HttpHeader.CONNECTION.asString(), HttpHeaderValue.CLOSE.asString());
+ break;
+ }
+ default:
+ {
+ throw new IllegalStateException();
+ }
+ }
+ }
+
private class HTTPPushStream extends StandardStream
{
private HTTPPushStream(int id, byte priority, ISession session, IStream associatedStream)