400555 HttpProxyEngine: Add http version header in response

This commit is contained in:
Thomas Becker 2013-02-12 12:15:51 +01:00
parent 4daba06175
commit c840d3dbb1
2 changed files with 5 additions and 1 deletions

View File

@ -30,6 +30,7 @@ import org.eclipse.jetty.client.util.DeferredContentProvider;
import org.eclipse.jetty.http.HttpField;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.spdy.api.ByteBufferDataInfo;
import org.eclipse.jetty.spdy.api.DataInfo;
import org.eclipse.jetty.spdy.api.HeadersInfo;
@ -235,9 +236,11 @@ public class HTTPProxyEngine extends ProxyEngine
Fields responseHeaders = new Fields();
for (HttpField header : response.getHeaders())
responseHeaders.add(header.getName(), header.getValue());
short version = clientStream.getSession().getVersion();
if (response.getStatus() > 0)
responseHeaders.add(HTTPSPDYHeader.STATUS.name(clientStream.getSession().getVersion()),
responseHeaders.add(HTTPSPDYHeader.STATUS.name(version),
String.valueOf(response.getStatus()));
responseHeaders.add(HTTPSPDYHeader.VERSION.name(version), HttpVersion.HTTP_1_1.asString());
addResponseProxyHeaders(clientStream, responseHeaders);
return responseHeaders;
}

View File

@ -179,6 +179,7 @@ public class ProxySPDYToHTTPTest
public void onReply(Stream stream, ReplyInfo replyInfo)
{
Fields headers = replyInfo.getHeaders();
assertThat("Version header is set", headers.get(HTTPSPDYHeader.VERSION.name(version)), is(notNullValue()));
assertThat("Custom set header foo is set on response", headers.get(header), is(notNullValue()));
assertThat("HOP headers like connection are removed before forwarding",
headers.get("connection"), is(nullValue()));