aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Becker2013-08-30 10:07:24 (EDT)
committerThomas Becker2013-08-30 11:19:47 (EDT)
commit8ba45188dbc76ebd81bacc100a78fa3af748c764 (patch)
treed24ffd5920ae13496368b31e8939608d39f13049
parent8e4bae0ccf97223b6f740a34ecc3ee1266231e29 (diff)
downloadorg.eclipse.jetty.project-8ba45188dbc76ebd81bacc100a78fa3af748c764.zip
org.eclipse.jetty.project-8ba45188dbc76ebd81bacc100a78fa3af748c764.tar.gz
org.eclipse.jetty.project-8ba45188dbc76ebd81bacc100a78fa3af748c764.tar.bz2
merge ProxyHTTPSPDYConnection change with 9.1
-rw-r--r--jetty-spdy/spdy-http-server/src/main/java/org/eclipse/jetty/spdy/server/proxy/ProxyHTTPSPDYConnection.java54
1 files changed, 50 insertions, 4 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 602255f..f2e1218 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
@@ -27,6 +27,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;
@@ -68,7 +69,7 @@ public class ProxyHTTPSPDYConnection extends HttpConnection implements HttpParse
public ProxyHTTPSPDYConnection(Connector connector, HttpConfiguration config, EndPoint endPoint, short version, ProxyEngineSelector proxyEngineSelector)
{
- super(config,connector,endPoint);
+ super(config, connector, endPoint);
this.version = version;
this.proxyEngineSelector = proxyEngineSelector;
this.session = new HTTPSession(version, connector);
@@ -95,7 +96,7 @@ public class ProxyHTTPSPDYConnection extends HttpConnection implements HttpParse
@Override
public boolean parsedHeader(HttpField field)
{
- if (field.getHeader()==HttpHeader.HOST)
+ if (field.getHeader() == HttpHeader.HOST)
headers.put(HTTPSPDYHeader.HOST.name(version), field.getValue());
else
headers.put(field.getName(), field.getValue());
@@ -144,10 +145,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
@@ -238,6 +245,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();
@@ -264,7 +273,7 @@ public class ProxyHTTPSPDYConnection extends HttpConnection implements HttpParse
long contentLength = fields.getLongField(HttpHeader.CONTENT_LENGTH.asString());
HttpGenerator.ResponseInfo info = new HttpGenerator.ResponseInfo(httpVersion, fields, contentLength, code,
reason, false);
-
+
// TODO use the async send
send(info, null, replyInfo.isClose());
@@ -317,6 +326,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)