Forwarded HttpParser.EventHandler methods from the inner class to the outer class (AbstractHttpConnection itself)
to allow other protocols such as SPDY to fake the emission of HTTP events by calling the EventHandler methods.
This commit is contained in:
parent
9781a734bd
commit
b0119e4d62
|
@ -117,6 +117,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
||||||
|
|
||||||
private int _version = UNKNOWN;
|
private int _version = UNKNOWN;
|
||||||
|
|
||||||
|
private String _charset;
|
||||||
private boolean _expect = false;
|
private boolean _expect = false;
|
||||||
private boolean _expect100Continue = false;
|
private boolean _expect100Continue = false;
|
||||||
private boolean _expect102Processing = false;
|
private boolean _expect102Processing = false;
|
||||||
|
@ -137,9 +138,6 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/** Constructor
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public AbstractHttpConnection(Connector connector, EndPoint endpoint, Server server)
|
public AbstractHttpConnection(Connector connector, EndPoint endpoint, Server server)
|
||||||
{
|
{
|
||||||
super(endpoint);
|
super(endpoint);
|
||||||
|
@ -250,28 +248,26 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* @return The result of calling {@link #getConnector}.{@link Connector#isConfidential(Request) isCondidential}(request), or false
|
* Find out if the request supports CONFIDENTIAL security.
|
||||||
* if there is no connector.
|
* @param request the incoming HTTP request
|
||||||
|
* @return the result of calling {@link Connector#isConfidential(Request)}, or false
|
||||||
|
* if there is no connector
|
||||||
*/
|
*/
|
||||||
public boolean isConfidential(Request request)
|
public boolean isConfidential(Request request)
|
||||||
{
|
{
|
||||||
if (_connector!=null)
|
return _connector != null && _connector.isConfidential(request);
|
||||||
return _connector.isConfidential(request);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
* Find out if the request is INTEGRAL security.
|
* Find out if the request supports INTEGRAL security.
|
||||||
* @param request
|
* @param request the incoming HTTP request
|
||||||
* @return <code>true</code> if there is a {@link #getConnector() connector} and it considers <code>request</code>
|
* @return the result of calling {@link Connector#isIntegral(Request)}, or false
|
||||||
* to be {@link Connector#isIntegral(Request) integral}
|
* if there is no connector
|
||||||
*/
|
*/
|
||||||
public boolean isIntegral(Request request)
|
public boolean isIntegral(Request request)
|
||||||
{
|
{
|
||||||
if (_connector!=null)
|
return _connector != null && _connector.isIntegral(request);
|
||||||
return _connector.isIntegral(request);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -311,6 +307,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
||||||
*
|
*
|
||||||
* @return The input stream for this connection.
|
* @return The input stream for this connection.
|
||||||
* The stream will be created if it does not already exist.
|
* The stream will be created if it does not already exist.
|
||||||
|
* @throws IOException if the input stream cannot be retrieved
|
||||||
*/
|
*/
|
||||||
public ServletInputStream getInputStream() throws IOException
|
public ServletInputStream getInputStream() throws IOException
|
||||||
{
|
{
|
||||||
|
@ -346,6 +343,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/**
|
/**
|
||||||
|
* @param encoding the PrintWriter encoding
|
||||||
* @return A {@link PrintWriter} wrapping the {@link #getOutputStream output stream}. The writer is created if it
|
* @return A {@link PrintWriter} wrapping the {@link #getOutputStream output stream}. The writer is created if it
|
||||||
* does not already exist.
|
* does not already exist.
|
||||||
*/
|
*/
|
||||||
|
@ -556,10 +554,6 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
||||||
_generator.setPersistent(false);
|
_generator.setPersistent(false);
|
||||||
_generator.completeHeader(_responseFields, last);
|
_generator.completeHeader(_responseFields, last);
|
||||||
}
|
}
|
||||||
catch(IOException io)
|
|
||||||
{
|
|
||||||
throw io;
|
|
||||||
}
|
|
||||||
catch(RuntimeException e)
|
catch(RuntimeException e)
|
||||||
{
|
{
|
||||||
LOG.warn("header full: " + e);
|
LOG.warn("header full: " + e);
|
||||||
|
@ -587,10 +581,6 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
||||||
{
|
{
|
||||||
_generator.completeHeader(_responseFields, Generator.LAST);
|
_generator.completeHeader(_responseFields, Generator.LAST);
|
||||||
}
|
}
|
||||||
catch(IOException io)
|
|
||||||
{
|
|
||||||
throw io;
|
|
||||||
}
|
|
||||||
catch(RuntimeException e)
|
catch(RuntimeException e)
|
||||||
{
|
{
|
||||||
LOG.warn("header full: "+e);
|
LOG.warn("header full: "+e);
|
||||||
|
@ -701,20 +691,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
||||||
_requests);
|
_requests);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
protected void startRequest(Buffer method, Buffer uri, Buffer version) throws IOException
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
private class RequestHandler extends HttpParser.EventHandler
|
|
||||||
{
|
|
||||||
private String _charset;
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* @see org.eclipse.jetty.server.server.HttpParser.EventHandler#startRequest(org.eclipse.io.Buffer,
|
|
||||||
* org.eclipse.io.Buffer, org.eclipse.io.Buffer)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void startRequest(Buffer method, Buffer uri, Buffer version) throws IOException
|
|
||||||
{
|
{
|
||||||
uri=uri.asImmutableBuffer();
|
uri=uri.asImmutableBuffer();
|
||||||
|
|
||||||
|
@ -773,11 +750,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
protected void parsedHeader(Buffer name, Buffer value) throws IOException
|
||||||
* @see org.eclipse.jetty.server.server.HttpParser.EventHandler#parsedHeaderValue(org.eclipse.io.Buffer)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void parsedHeader(Buffer name, Buffer value)
|
|
||||||
{
|
{
|
||||||
int ho = HttpHeaders.CACHE.getOrdinal(name);
|
int ho = HttpHeaders.CACHE.getOrdinal(name);
|
||||||
switch (ho)
|
switch (ho)
|
||||||
|
@ -838,11 +811,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
||||||
_requestFields.add(name, value);
|
_requestFields.add(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
protected void headerComplete() throws IOException
|
||||||
* @see org.eclipse.jetty.server.server.HttpParser.EventHandler#headerComplete()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void headerComplete() throws IOException
|
|
||||||
{
|
{
|
||||||
_requests++;
|
_requests++;
|
||||||
_generator.setVersion(_version);
|
_generator.setVersion(_version);
|
||||||
|
@ -912,6 +881,58 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
||||||
_delayedHandling=true;
|
_delayedHandling=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void content(Buffer buffer) throws IOException
|
||||||
|
{
|
||||||
|
if (_delayedHandling)
|
||||||
|
{
|
||||||
|
_delayedHandling=false;
|
||||||
|
handleRequest();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void messageComplete(long contentLength) throws IOException
|
||||||
|
{
|
||||||
|
if (_delayedHandling)
|
||||||
|
{
|
||||||
|
_delayedHandling=false;
|
||||||
|
handleRequest();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
/* ------------------------------------------------------------ */
|
||||||
|
private class RequestHandler extends HttpParser.EventHandler
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* @see org.eclipse.jetty.server.server.HttpParser.EventHandler#startRequest(org.eclipse.io.Buffer,
|
||||||
|
* org.eclipse.io.Buffer, org.eclipse.io.Buffer)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void startRequest(Buffer method, Buffer uri, Buffer version) throws IOException
|
||||||
|
{
|
||||||
|
AbstractHttpConnection.this.startRequest(method, uri, version);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see org.eclipse.jetty.server.server.HttpParser.EventHandler#parsedHeaderValue(org.eclipse.io.Buffer)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void parsedHeader(Buffer name, Buffer value) throws IOException
|
||||||
|
{
|
||||||
|
AbstractHttpConnection.this.parsedHeader(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @see org.eclipse.jetty.server.server.HttpParser.EventHandler#headerComplete()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void headerComplete() throws IOException
|
||||||
|
{
|
||||||
|
AbstractHttpConnection.this.headerComplete();
|
||||||
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.jetty.server.server.HttpParser.EventHandler#content(int, org.eclipse.io.Buffer)
|
* @see org.eclipse.jetty.server.server.HttpParser.EventHandler#content(int, org.eclipse.io.Buffer)
|
||||||
|
@ -919,11 +940,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
||||||
@Override
|
@Override
|
||||||
public void content(Buffer ref) throws IOException
|
public void content(Buffer ref) throws IOException
|
||||||
{
|
{
|
||||||
if (_delayedHandling)
|
AbstractHttpConnection.this.content(ref);
|
||||||
{
|
|
||||||
_delayedHandling=false;
|
|
||||||
handleRequest();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -935,11 +952,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
||||||
@Override
|
@Override
|
||||||
public void messageComplete(long contentLength) throws IOException
|
public void messageComplete(long contentLength) throws IOException
|
||||||
{
|
{
|
||||||
if (_delayedHandling)
|
AbstractHttpConnection.this.messageComplete(contentLength);
|
||||||
{
|
|
||||||
_delayedHandling=false;
|
|
||||||
handleRequest();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
@ -955,10 +968,8 @@ public abstract class AbstractHttpConnection extends AbstractConnection
|
||||||
if (LOG.isDebugEnabled())
|
if (LOG.isDebugEnabled())
|
||||||
LOG.debug("Bad request!: "+version+" "+status+" "+reason);
|
LOG.debug("Bad request!: "+version+" "+status+" "+reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
/* ------------------------------------------------------------ */
|
/* ------------------------------------------------------------ */
|
||||||
|
|
Loading…
Reference in New Issue