Added factory method to create the HttpChannel.
This commit is contained in:
parent
cdfa515ca3
commit
4eef2a347f
|
@ -82,6 +82,11 @@ public class HttpConnectionOverFCGI extends AbstractConnection implements Connec
|
|||
return destination;
|
||||
}
|
||||
|
||||
protected Flusher getFlusher()
|
||||
{
|
||||
return flusher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Request request, Response.CompleteListener listener)
|
||||
{
|
||||
|
@ -270,6 +275,11 @@ public class HttpConnectionOverFCGI extends AbstractConnection implements Connec
|
|||
}
|
||||
}
|
||||
|
||||
protected HttpChannelOverFCGI newHttpChannel(int id, Request request)
|
||||
{
|
||||
return new HttpChannelOverFCGI(this, getFlusher(), id, request.getIdleTimeout());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
@ -295,7 +305,7 @@ public class HttpConnectionOverFCGI extends AbstractConnection implements Connec
|
|||
|
||||
// FCGI may be multiplexed, so create one channel for each request.
|
||||
int id = acquireRequest();
|
||||
HttpChannelOverFCGI channel = new HttpChannelOverFCGI(HttpConnectionOverFCGI.this, flusher, id, request.getIdleTimeout());
|
||||
HttpChannelOverFCGI channel = newHttpChannel(id, request);
|
||||
channels.put(id, channel);
|
||||
if (channel.associate(exchange))
|
||||
channel.send();
|
||||
|
|
|
@ -41,12 +41,17 @@ public class HttpConnectionOverHTTP2 extends HttpConnection
|
|||
this.session = session;
|
||||
}
|
||||
|
||||
public Session getSession()
|
||||
{
|
||||
return session;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void send(HttpExchange exchange)
|
||||
{
|
||||
normalizeRequest(exchange.getRequest());
|
||||
// One connection maps to N channels, so for each exchange we create a new channel.
|
||||
HttpChannel channel = new HttpChannelOverHTTP2(getHttpDestination(), this, session);
|
||||
HttpChannel channel = newHttpChannel();
|
||||
channels.add(channel);
|
||||
if (channel.associate(exchange))
|
||||
channel.send();
|
||||
|
@ -54,6 +59,11 @@ public class HttpConnectionOverHTTP2 extends HttpConnection
|
|||
channel.release();
|
||||
}
|
||||
|
||||
protected HttpChannelOverHTTP2 newHttpChannel()
|
||||
{
|
||||
return new HttpChannelOverHTTP2(getHttpDestination(), this, getSession());
|
||||
}
|
||||
|
||||
protected void release(HttpChannel channel)
|
||||
{
|
||||
channels.remove(channel);
|
||||
|
|
Loading…
Reference in New Issue