Added support for X-Forwarded-For header.

This commit is contained in:
Simone Bordet 2012-07-12 17:45:00 +02:00
parent a7dab4bd2d
commit 1843324bab
3 changed files with 7 additions and 2 deletions

View File

@ -73,6 +73,9 @@ public abstract class ProxyEngine extends ServerSessionFrameListener.Adapter imp
protected void addRequestProxyHeaders(Stream stream, Headers headers)
{
addViaHeader(headers);
String address = (String)stream.getSession().getAttribute("org.eclipse.jetty.spdy.remoteAddress");
if (address != null)
headers.add("X-Forwarded-For", address);
}
protected void addResponseProxyHeaders(Stream stream, Headers headers)

View File

@ -59,13 +59,14 @@ public class ProxyHTTPSPDYAsyncConnection extends AsyncHttpConnection
private Stream stream;
private Buffer content;
public ProxyHTTPSPDYAsyncConnection(SPDYServerConnector connector, EndPoint endpoint, short version, ProxyEngine proxyEngine)
public ProxyHTTPSPDYAsyncConnection(SPDYServerConnector connector, EndPoint endPoint, short version, ProxyEngine proxyEngine)
{
super(connector, endpoint, connector.getServer());
super(connector, endPoint, connector.getServer());
this.version = version;
this.proxyEngine = proxyEngine;
this.generator = (HttpGenerator)_generator;
this.session = new HTTPSession(version, connector);
this.session.setAttribute("org.eclipse.jetty.spdy.remoteAddress", endPoint.getRemoteAddr());
}
@Override

View File

@ -69,6 +69,7 @@ public class ServerSPDYAsyncConnectionFactory implements AsyncConnectionFactory
FlowControlStrategy flowControlStrategy = connector.newFlowControlStrategy(version);
StandardSession session = new StandardSession(version, bufferPool, threadPool, scheduler, connection, connection, 2, listener, generator, flowControlStrategy);
session.setAttribute("org.eclipse.jetty.spdy.remoteAddress", endPoint.getRemoteAddr());
session.setWindowSize(connector.getInitialWindowSize());
parser.addListener(session);
connection.setSession(session);