jetty-9 moved more fields out of HttpChannel

This commit is contained in:
Greg Wilkins 2012-08-17 16:41:53 +10:00
parent 78a529fc9d
commit e7cad67ace
2 changed files with 24 additions and 19 deletions

View File

@ -73,7 +73,6 @@ public abstract class HttpChannel
private final HttpChannelState _state;
private final Request _request;
private final HttpInput _in;
private final Response _response;
@ -94,9 +93,8 @@ public abstract class HttpChannel
_connection = connection;
_uri = new HttpURI(URIUtil.__CHARSET);
_state = new HttpChannelState(this);
_request = new Request(this);
_request = new Request(this,input);
_response = new Response(this,new Output());
_in=input;
}
/* ------------------------------------------------------------ */
@ -176,8 +174,6 @@ public abstract class HttpChannel
/* ------------------------------------------------------------ */
/**
* Get the inputStream from the connection.
* <p>
* If the associated response has the Expect header set to 100 Continue,
* then accessing the input stream indicates that the handler/servlet
* is ready for the request body and thus a 100 Continue response is sent.
@ -186,13 +182,13 @@ public abstract class HttpChannel
* The stream will be created if it does not already exist.
* @throws IOException if the InputStream cannot be created
*/
public ServletInputStream getInputStream() throws IOException
public void continue100(int available) throws IOException
{
// If the client is expecting 100 CONTINUE, then send it now.
if (_expect100Continue)
{
// is content missing?
if (_in.available()==0)
if (available==0)
{
if (_response.isCommitted())
throw new IllegalStateException("Committed before 100 Continues");
@ -200,12 +196,8 @@ public abstract class HttpChannel
}
_expect100Continue=false;
}
return _in;
}
/* ------------------------------------------------------------ */
public void reset()
{
@ -215,7 +207,6 @@ public abstract class HttpChannel
_request.recycle();
_response.recycle();
_uri.clear();
_in.recycle(); // TODO done here or in connection?
}
/* ------------------------------------------------------------ */
@ -321,7 +312,7 @@ public abstract class HttpChannel
_response.complete();
// Complete reading the request
_in.consumeAll();
_request.getHttpInput().consumeAll();
}
catch(EofException e)
{
@ -375,7 +366,7 @@ public abstract class HttpChannel
{
if (_state.isIdle())
_state.complete();
_in.shutdownInput();
_request.getHttpInput().shutdownInput();
}
return false;
}
@ -562,21 +553,21 @@ public abstract class HttpChannel
{
LOG.debug("{} content {}",this,BufferUtil.toDetailString(ref));
}
_in.content(ref);
_request.getHttpInput().content(ref);
return true;
}
@Override
public boolean messageComplete(long contentLength)
{
_in.shutdownInput();
_request.getHttpInput().shutdownInput();
return true;
}
@Override
public boolean earlyEOF()
{
_in.shutdownInput();
_request.getHttpInput().shutdownInput();
return false;
}

View File

@ -120,6 +120,8 @@ public class Request implements HttpServletRequest
private final List<ServletRequestAttributeListener> _requestAttributeListeners=new ArrayList<>();
private final HttpInput _in;
private boolean _asyncSupported = true;
private volatile Attributes _attributes;
private Authentication _authentication;
@ -164,10 +166,11 @@ public class Request implements HttpServletRequest
/* ------------------------------------------------------------ */
public Request(HttpChannel channel)
public Request(HttpChannel channel, HttpInput in)
{
_channel = channel;
_state=channel.getState();
_in=in;
}
/* ------------------------------------------------------------ */
@ -175,6 +178,12 @@ public class Request implements HttpServletRequest
{
return _fields;
}
/* ------------------------------------------------------------ */
public HttpInput getHttpInput()
{
return _in;
}
/* ------------------------------------------------------------ */
public void addEventListener(final EventListener listener)
@ -530,7 +539,11 @@ public class Request implements HttpServletRequest
if (_inputState != __NONE && _inputState != _STREAM)
throw new IllegalStateException("READER");
_inputState = _STREAM;
return _channel.getInputStream();
if (_channel.isExpecting100Continues())
_channel.continue100(_in.available());
return _in;
}
/* ------------------------------------------------------------ */
@ -1440,6 +1453,7 @@ public class Request implements HttpServletRequest
_multiPartInputStream = null;
_remote=null;
_fields.clear();
_in.recycle(); // TODO done here or in connection?
}
/* ------------------------------------------------------------ */