Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Request.java4
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java3
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/AsyncHttpConnection.java5
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpExchangeCancelTest.java6
-rw-r--r--jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java1314
-rw-r--r--jetty-io/src/main/java/org/eclipse/jetty/io/AsyncEndPoint.java6
-rw-r--r--jetty-io/src/main/java/org/eclipse/jetty/io/EofException.java7
-rw-r--r--jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java25
-rw-r--r--jetty-security/src/main/java/org/eclipse/jetty/security/ConstraintSecurityHandler.java4
-rw-r--r--jetty-security/src/main/java/org/eclipse/jetty/security/authentication/FormAuthenticator.java6
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java4
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java (renamed from jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java)26
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java4
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java2
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/BlockingHttpConnection.java2
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java4
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/Handler.java4
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java4
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java4
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java2
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/Request.java16
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/Response.java4
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/Server.java4
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/bio/SocketConnector.java6
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/handler/ConnectHandler.java6
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java4
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/handler/ErrorHandler.java4
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/handler/IPAccessHandler.java4
-rw-r--r--jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java6
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/AsyncRequestReadTest.java (renamed from jetty-server/src/test/java/org/eclipse/jetty/server/AsyncUploadTest.java)5
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java8
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java4
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/HttpWriterTest.java4
-rw-r--r--jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java16
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java10
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ErrorPageErrorHandler.java4
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/Invoker.java4
-rw-r--r--jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java6
-rw-r--r--jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CloseableDoSFilter.java4
-rw-r--r--jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java4
40 files changed, 774 insertions, 785 deletions
diff --git a/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Request.java b/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Request.java
index bde26f7a2a..df92aec440 100644
--- a/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Request.java
+++ b/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Request.java
@@ -13,7 +13,7 @@
package org.eclipse.jetty.ajp;
-import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.AbstractHttpConnection;
import org.eclipse.jetty.server.Request;
public class Ajp13Request extends Request
@@ -24,7 +24,7 @@ public class Ajp13Request extends Request
protected boolean _sslSecure;
/* ------------------------------------------------------------ */
- public Ajp13Request(HttpConnection connection)
+ public Ajp13Request(AbstractHttpConnection connection)
{
super(connection);
}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java
index bb143be281..24502b41e4 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/AbstractHttpConnection.java
@@ -36,6 +36,7 @@ import org.eclipse.jetty.io.Buffers;
import org.eclipse.jetty.io.ByteArrayBuffer;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
+import org.eclipse.jetty.io.EofException;
import org.eclipse.jetty.io.View;
import org.eclipse.jetty.util.component.AggregateLifeCycle;
import org.eclipse.jetty.util.component.Dumpable;
@@ -394,7 +395,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen
String exch= exchange.toString();
String reason = _endp.isOpen()?(_endp.isInputShutdown()?"half closed: ":"local close: "):"closed: ";
exchange.setStatus(HttpExchange.STATUS_EXCEPTED);
- exchange.getEventListener().onException(new EOFException(reason+exch));
+ exchange.getEventListener().onException(new EofException(reason+exch));
}
}
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/AsyncHttpConnection.java b/jetty-client/src/main/java/org/eclipse/jetty/client/AsyncHttpConnection.java
index ea0d8f2b12..6fc12f5af6 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/AsyncHttpConnection.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/AsyncHttpConnection.java
@@ -58,13 +58,14 @@ public class AsyncHttpConnection extends AbstractHttpConnection implements Async
if (exchange == null)
{
- long filled = _parser.fill();
+ // TODO long filled = _parser.fill();
+ long filled = -1;
if (filled < 0)
close();
else
{
// Hopefully just space?
- _parser.skipCRLF();
+ // TODO _parser.skipCRLF();
if (_parser.isMoreInBuffer())
{
LOG.warn("Unexpected data received but no request sent");
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpExchangeCancelTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpExchangeCancelTest.java
index b50dc29005..7ccaaebadc 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpExchangeCancelTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/AbstractHttpExchangeCancelTest.java
@@ -28,7 +28,7 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.server.Connector;
-import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.AbstractHttpConnection;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.AbstractHandler;
@@ -320,7 +320,7 @@ public abstract class AbstractHttpExchangeCancelTest
{
try
{
- ((StdErrLog)Log.getLogger(HttpConnection.class)).setHideStacks(true);
+ ((StdErrLog)Log.getLogger(AbstractHttpConnection.class)).setHideStacks(true);
TestHttpExchange exchange = new TestHttpExchange();
exchange.setAddress(newAddress());
exchange.setRequestURI("/?action=throw");
@@ -335,7 +335,7 @@ public abstract class AbstractHttpExchangeCancelTest
}
finally
{
- ((StdErrLog)Log.getLogger(HttpConnection.class)).setHideStacks(false);
+ ((StdErrLog)Log.getLogger(AbstractHttpConnection.class)).setHideStacks(false);
}
}
diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java
index 41a45cc4fd..f23eae5416 100644
--- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java
+++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java
@@ -14,6 +14,8 @@
package org.eclipse.jetty.http;
import java.io.IOException;
+import java.util.concurrent.locks.Lock;
+import java.util.concurrent.locks.ReentrantLock;
import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.BufferCache.CachedBuffer;
@@ -80,6 +82,8 @@ public class HttpParser implements Parser
protected int _chunkLength;
protected int _chunkPosition;
private boolean _headResponse;
+
+ private Lock _lock = new ReentrantLock(); // Ensure only a single parsing/resetting thread
/* ------------------------------------------------------------------------------- */
/**
@@ -247,217 +251,178 @@ public class HttpParser implements Parser
* @return an indication of progress <0 EOF, 0 no progress, >0 progress.
*/
public int parseNext() throws IOException
- {
- int progress=0;
+ {
+ _lock.lock();
+ try
+ {
+ int progress=0;
- if (_state == STATE_END)
- return 0;
+ if (_state == STATE_END)
+ return 0;
- if (_buffer==null)
- {
- if (_header == null)
+ if (_buffer==null)
{
- _header=_buffers.getHeader();
+ if (_header == null)
+ {
+ _header=_buffers.getHeader();
+ }
+ _buffer=_header;
+ _tok0=new View.CaseInsensitive(_header);
+ _tok1=new View.CaseInsensitive(_header);
+ _tok0.setPutIndex(_tok0.getIndex());
+ _tok1.setPutIndex(_tok1.getIndex());
}
- _buffer=_header;
- _tok0=new View.CaseInsensitive(_header);
- _tok1=new View.CaseInsensitive(_header);
- _tok0.setPutIndex(_tok0.getIndex());
- _tok1.setPutIndex(_tok1.getIndex());
- }
- if (_state == STATE_CONTENT && _contentPosition == _contentLength)
- {
- _state=STATE_END;
- _handler.messageComplete(_contentPosition);
- return 1;
- }
-
- int length=_buffer.length();
-
- // Fill buffer if we can
- if (length == 0)
- {
- long filled=-1;
- IOException ex=null;
- try
+ if (_state == STATE_CONTENT && _contentPosition == _contentLength)
{
- filled=fill();
- }
- catch(IOException e)
- {
- LOG.debug(this.toString(),e);
- ex=e;
+ _state=STATE_END;
+ _handler.messageComplete(_contentPosition);
+ return 1;
}
- if (filled < 0 || _endp.isInputShutdown())
+ int length=_buffer.length();
+
+ // Fill buffer if we can
+ if (length == 0)
{
- _persistent=false;
-
- // do we have content to deliver?
- if (_state>STATE_END)
+ int filled=-1;
+ IOException ex=null;
+ try
{
- if (_buffer.length()>0 && !_headResponse)
- {
- Buffer chunk=_buffer.get(_buffer.length());
- _contentPosition += chunk.length();
- _contentView.update(chunk);
- _handler.content(chunk); // May recurse here
- }
+ filled=fill();
+ }
+ catch(IOException e)
+ {
+ LOG.debug(this.toString(),e);
+ ex=e;
}
- // was this unexpected?
- switch(_state)
+ if (filled < 0 || _endp.isInputShutdown())
{
- case STATE_END:
- case STATE_SEEKING_EOF:
- _state=STATE_END;
- break;
+ _persistent=false;
- case STATE_EOF_CONTENT:
- _state=STATE_END;
- _handler.messageComplete(_contentPosition);
- break;
-
- default:
- _state=STATE_END;
- _handler.earlyEOF();
- _handler.messageComplete(_contentPosition);
- }
-
- if (ex!=null)
- throw ex;
+ // do we have content to deliver?
+ if (_state>STATE_END)
+ {
+ if (_buffer.length()>0 && !_headResponse)
+ {
+ Buffer chunk=_buffer.get(_buffer.length());
+ _contentPosition += chunk.length();
+ _contentView.update(chunk);
+ _handler.content(chunk); // May recurse here
+ }
+ }
- if (!isComplete() && !isIdle())
- throw new EofException();
+ // was this unexpected?
+ switch(_state)
+ {
+ case STATE_END:
+ case STATE_SEEKING_EOF:
+ _state=STATE_END;
+ break;
- return -1;
- }
- length=_buffer.length();
- }
+ case STATE_EOF_CONTENT:
+ _state=STATE_END;
+ _handler.messageComplete(_contentPosition);
+ break;
+ default:
+ _state=STATE_END;
+ _handler.earlyEOF();
+ _handler.messageComplete(_contentPosition);
+ }
- // Handle header states
- byte ch;
- byte[] array=_buffer.array();
- int last=_state;
- while (_state<STATE_END && length-->0)
- {
- if (last!=_state)
- {
- progress++;
- last=_state;
- }
+ if (ex!=null)
+ throw ex;
- ch=_buffer.get();
+ if (!isComplete() && !isIdle())
+ throw new EofException();
- if (_eol == HttpTokens.CARRIAGE_RETURN && ch == HttpTokens.LINE_FEED)
- {
- _eol=HttpTokens.LINE_FEED;
- continue;
+ return -1;
+ }
+ length=_buffer.length();
}
- _eol=0;
- switch (_state)
+
+ // Handle header states
+ byte ch;
+ byte[] array=_buffer.array();
+ int last=_state;
+ while (_state<STATE_END && length-->0)
{
- case STATE_START:
- _contentLength=HttpTokens.UNKNOWN_CONTENT;
- _cached=null;
- if (ch > HttpTokens.SPACE || ch<0)
- {
- _buffer.mark();
- _state=STATE_FIELD0;
- }
- break;
+ if (last!=_state)
+ {
+ progress++;
+ last=_state;
+ }
- case STATE_FIELD0:
- if (ch == HttpTokens.SPACE)
- {
- _tok0.update(_buffer.markIndex(), _buffer.getIndex() - 1);
- _responseStatus=HttpVersions.CACHE.get(_tok0)==null?-1:0;
- _state=STATE_SPACE1;
- continue;
- }
- else if (ch < HttpTokens.SPACE && ch>=0)
- {
- throw new HttpException(HttpStatus.BAD_REQUEST_400);
- }
- break;
+ ch=_buffer.get();
- case STATE_SPACE1:
- if (ch > HttpTokens.SPACE || ch<0)
- {
- _buffer.mark();
- if (_responseStatus>=0)
+ if (_eol == HttpTokens.CARRIAGE_RETURN && ch == HttpTokens.LINE_FEED)
+ {
+ _eol=HttpTokens.LINE_FEED;
+ continue;
+ }
+ _eol=0;
+
+ switch (_state)
+ {
+ case STATE_START:
+ _contentLength=HttpTokens.UNKNOWN_CONTENT;
+ _cached=null;
+ if (ch > HttpTokens.SPACE || ch<0)
{
- _state=STATE_STATUS;
- _responseStatus=ch-'0';
+ _buffer.mark();
+ _state=STATE_FIELD0;
}
- else
- _state=STATE_URI;
- }
- else if (ch < HttpTokens.SPACE)
- {
- throw new HttpException(HttpStatus.BAD_REQUEST_400);
- }
- break;
+ break;
- case STATE_STATUS:
- if (ch == HttpTokens.SPACE)
- {
- _tok1.update(_buffer.markIndex(), _buffer.getIndex() - 1);
- _state=STATE_SPACE2;
- continue;
- }
- else if (ch>='0' && ch<='9')
- {
- _responseStatus=_responseStatus*10+(ch-'0');
- continue;
- }
- else if (ch < HttpTokens.SPACE && ch>=0)
- {
- _handler.startResponse(HttpMethods.CACHE.lookup(_tok0), _responseStatus, null);
- _eol=ch;
- _state=STATE_HEADER;
- _tok0.setPutIndex(_tok0.getIndex());
- _tok1.setPutIndex(_tok1.getIndex());
- _multiLineValue=null;
- continue;
- }
- // not a digit, so must be a URI
- _state=STATE_URI;
- _responseStatus=-1;
- break;
+ case STATE_FIELD0:
+ if (ch == HttpTokens.SPACE)
+ {
+ _tok0.update(_buffer.markIndex(), _buffer.getIndex() - 1);
+ _responseStatus=HttpVersions.CACHE.get(_tok0)==null?-1:0;
+ _state=STATE_SPACE1;
+ continue;
+ }
+ else if (ch < HttpTokens.SPACE && ch>=0)
+ {
+ throw new HttpException(HttpStatus.BAD_REQUEST_400);
+ }
+ break;
- case STATE_URI:
- if (ch == HttpTokens.SPACE)
- {
- _tok1.update(_buffer.markIndex(), _buffer.getIndex() - 1);
- _state=STATE_SPACE2;
- continue;
- }
- else if (ch < HttpTokens.SPACE && ch>=0)
- {
- // HTTP/0.9
- _handler.startRequest(HttpMethods.CACHE.lookup(_tok0), _buffer.sliceFromMark(), null);
- _persistent=false;
- _state=STATE_SEEKING_EOF;
- _handler.headerComplete();
- _handler.messageComplete(_contentPosition);
- return 1;
- }
- break;
+ case STATE_SPACE1:
+ if (ch > HttpTokens.SPACE || ch<0)
+ {
+ _buffer.mark();
+ if (_responseStatus>=0)
+ {
+ _state=STATE_STATUS;
+ _responseStatus=ch-'0';
+ }
+ else
+ _state=STATE_URI;
+ }
+ else if (ch < HttpTokens.SPACE)
+ {
+ throw new HttpException(HttpStatus.BAD_REQUEST_400);
+ }
+ break;
- case STATE_SPACE2:
- if (ch > HttpTokens.SPACE || ch<0)
- {
- _buffer.mark();
- _state=STATE_FIELD2;
- }
- else if (ch < HttpTokens.SPACE)
- {
- if (_responseStatus>0)
+ case STATE_STATUS:
+ if (ch == HttpTokens.SPACE)
+ {
+ _tok1.update(_buffer.markIndex(), _buffer.getIndex() - 1);
+ _state=STATE_SPACE2;
+ continue;
+ }
+ else if (ch>='0' && ch<='9')
+ {
+ _responseStatus=_responseStatus*10+(ch-'0');
+ continue;
+ }
+ else if (ch < HttpTokens.SPACE && ch>=0)
{
_handler.startResponse(HttpMethods.CACHE.lookup(_tok0), _responseStatus, null);
_eol=ch;
@@ -465,512 +430,559 @@ public class HttpParser implements Parser
_tok0.setPutIndex(_tok0.getIndex());
_tok1.setPutIndex(_tok1.getIndex());
_multiLineValue=null;
+ continue;
}
- else
+ // not a digit, so must be a URI
+ _state=STATE_URI;
+ _responseStatus=-1;
+ break;
+
+ case STATE_URI:
+ if (ch == HttpTokens.SPACE)
+ {
+ _tok1.update(_buffer.markIndex(), _buffer.getIndex() - 1);
+ _state=STATE_SPACE2;
+ continue;
+ }
+ else if (ch < HttpTokens.SPACE && ch>=0)
{
// HTTP/0.9
- _handler.startRequest(HttpMethods.CACHE.lookup(_tok0), _tok1, null);
+ _handler.startRequest(HttpMethods.CACHE.lookup(_tok0), _buffer.sliceFromMark(), null);
_persistent=false;
_state=STATE_SEEKING_EOF;
_handler.headerComplete();
_handler.messageComplete(_contentPosition);
return 1;
}
- }
- break;
+ break;
- case STATE_FIELD2:
- if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED)
- {
- Buffer version;
- if (_responseStatus>0)
- _handler.startResponse(version=HttpVersions.CACHE.lookup(_tok0), _responseStatus,_buffer.sliceFromMark());
- else
- _handler.startRequest(HttpMethods.CACHE.lookup(_tok0), _tok1, version=HttpVersions.CACHE.lookup(_buffer.sliceFromMark()));
- _eol=ch;
- _persistent=HttpVersions.CACHE.getOrdinal(version)>=HttpVersions.HTTP_1_1_ORDINAL;
- _state=STATE_HEADER;
- _tok0.setPutIndex(_tok0.getIndex());
- _tok1.setPutIndex(_tok1.getIndex());
- _multiLineValue=null;
- continue;
- }
- break;
+ case STATE_SPACE2:
+ if (ch > HttpTokens.SPACE || ch<0)
+ {
+ _buffer.mark();
+ _state=STATE_FIELD2;
+ }
+ else if (ch < HttpTokens.SPACE)
+ {
+ if (_responseStatus>0)
+ {
+ _handler.startResponse(HttpMethods.CACHE.lookup(_tok0), _responseStatus, null);
+ _eol=ch;
+ _state=STATE_HEADER;
+ _tok0.setPutIndex(_tok0.getIndex());
+ _tok1.setPutIndex(_tok1.getIndex());
+ _multiLineValue=null;
+ }
+ else
+ {
+ // HTTP/0.9
+ _handler.startRequest(HttpMethods.CACHE.lookup(_tok0), _tok1, null);
+ _persistent=false;
+ _state=STATE_SEEKING_EOF;
+ _handler.headerComplete();
+ _handler.messageComplete(_contentPosition);
+ return 1;
+ }
+ }
+ break;
- case STATE_HEADER:
- switch(ch)
- {
- case HttpTokens.COLON:
- case HttpTokens.SPACE:
- case HttpTokens.TAB:
+ case STATE_FIELD2:
+ if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED)
{
- // header value without name - continuation?
- _length=-1;
- _state=STATE_HEADER_VALUE;
- break;
+ Buffer version;
+ if (_responseStatus>0)
+ _handler.startResponse(version=HttpVersions.CACHE.lookup(_tok0), _responseStatus,_buffer.sliceFromMark());
+ else
+ _handler.startRequest(HttpMethods.CACHE.lookup(_tok0), _tok1, version=HttpVersions.CACHE.lookup(_buffer.sliceFromMark()));
+ _eol=ch;
+ _persistent=HttpVersions.CACHE.getOrdinal(version)>=HttpVersions.HTTP_1_1_ORDINAL;
+ _state=STATE_HEADER;
+ _tok0.setPutIndex(_tok0.getIndex());
+ _tok1.setPutIndex(_tok1.getIndex());
+ _multiLineValue=null;
+ continue;
}
+ break;
- default:
+ case STATE_HEADER:
+ switch(ch)
{
- // handler last header if any
- if (_cached!=null || _tok0.length() > 0 || _tok1.length() > 0 || _multiLineValue != null)
+ case HttpTokens.COLON:
+ case HttpTokens.SPACE:
+ case HttpTokens.TAB:
{
- Buffer header=_cached!=null?_cached:HttpHeaders.CACHE.lookup(_tok0);
- _cached=null;
- Buffer value=_multiLineValue == null ? _tok1 : new ByteArrayBuffer(_multiLineValue);
+ // header value without name - continuation?
+ _length=-1;
+ _state=STATE_HEADER_VALUE;
+ break;
+ }
- int ho=HttpHeaders.CACHE.getOrdinal(header);
- if (ho >= 0)
+ default:
+ {
+ // handler last header if any
+ if (_cached!=null || _tok0.length() > 0 || _tok1.length() > 0 || _multiLineValue != null)
{
- int vo;
+ Buffer header=_cached!=null?_cached:HttpHeaders.CACHE.lookup(_tok0);
+ _cached=null;
+ Buffer value=_multiLineValue == null ? _tok1 : new ByteArrayBuffer(_multiLineValue);
- switch (ho)
+ int ho=HttpHeaders.CACHE.getOrdinal(header);
+ if (ho >= 0)
{
- case HttpHeaders.CONTENT_LENGTH_ORDINAL:
- if (_contentLength != HttpTokens.CHUNKED_CONTENT && _responseStatus!=304 && _responseStatus!=204 && (_responseStatus<100 || _responseStatus>=200))
- {
- try
- {
- _contentLength=BufferUtil.toLong(value);
- }
- catch(NumberFormatException e)
+ int vo;
+
+ switch (ho)
+ {
+ case HttpHeaders.CONTENT_LENGTH_ORDINAL:
+ if (_contentLength != HttpTokens.CHUNKED_CONTENT && _responseStatus!=304 && _responseStatus!=204 && (_responseStatus<100 || _responseStatus>=200))
{
- LOG.ignore(e);
- throw new HttpException(HttpStatus.BAD_REQUEST_400);
+ try
+ {
+ _contentLength=BufferUtil.toLong(value);
+ }
+ catch(NumberFormatException e)
+ {
+ LOG.ignore(e);
+ throw new HttpException(HttpStatus.BAD_REQUEST_400);
+ }
+ if (_contentLength <= 0)
+ _contentLength=HttpTokens.NO_CONTENT;
}
- if (_contentLength <= 0)
- _contentLength=HttpTokens.NO_CONTENT;
- }
- break;
+ break;
- case HttpHeaders.TRANSFER_ENCODING_ORDINAL:
- value=HttpHeaderValues.CACHE.lookup(value);
- vo=HttpHeaderValues.CACHE.getOrdinal(value);
- if (HttpHeaderValues.CHUNKED_ORDINAL == vo)
- _contentLength=HttpTokens.CHUNKED_CONTENT;
- else
- {
- String c=value.toString(StringUtil.__ISO_8859_1);
- if (c.endsWith(HttpHeaderValues.CHUNKED))
+ case HttpHeaders.TRANSFER_ENCODING_ORDINAL:
+ value=HttpHeaderValues.CACHE.lookup(value);
+ vo=HttpHeaderValues.CACHE.getOrdinal(value);
+ if (HttpHeaderValues.CHUNKED_ORDINAL == vo)
_contentLength=HttpTokens.CHUNKED_CONTENT;
+ else
+ {
+ String c=value.toString(StringUtil.__ISO_8859_1);
+ if (c.endsWith(HttpHeaderValues.CHUNKED))
+ _contentLength=HttpTokens.CHUNKED_CONTENT;
- else if (c.indexOf(HttpHeaderValues.CHUNKED) >= 0)
- throw new HttpException(400,null);
- }
- break;
+ else if (c.indexOf(HttpHeaderValues.CHUNKED) >= 0)
+ throw new HttpException(400,null);
+ }
+ break;
- case HttpHeaders.CONNECTION_ORDINAL:
- switch(HttpHeaderValues.CACHE.getOrdinal(value))
- {
- case HttpHeaderValues.CLOSE_ORDINAL:
- _persistent=false;
- break;
-
- case HttpHeaderValues.KEEP_ALIVE_ORDINAL:
- _persistent=true;
- break;
-
- case -1: // No match, may be multi valued
+ case HttpHeaders.CONNECTION_ORDINAL:
+ switch(HttpHeaderValues.CACHE.getOrdinal(value))
{
- for (String v : value.toString().split(","))
+ case HttpHeaderValues.CLOSE_ORDINAL:
+ _persistent=false;
+ break;
+
+ case HttpHeaderValues.KEEP_ALIVE_ORDINAL:
+ _persistent=true;
+ break;
+
+ case -1: // No match, may be multi valued
{
- switch(HttpHeaderValues.CACHE.getOrdinal(v.trim()))
+ for (String v : value.toString().split(","))
{
- case HttpHeaderValues.CLOSE_ORDINAL:
- _persistent=false;
- break;
-
- case HttpHeaderValues.KEEP_ALIVE_ORDINAL:
- _persistent=true;
- break;
+ switch(HttpHeaderValues.CACHE.getOrdinal(v.trim()))
+ {
+ case HttpHeaderValues.CLOSE_ORDINAL:
+ _persistent=false;
+ break;
+
+ case HttpHeaderValues.KEEP_ALIVE_ORDINAL:
+ _persistent=true;
+ break;
+ }
}
+ break;
}
- break;
}
- }
+ }
}
- }
- _handler.parsedHeader(header, value);
- _tok0.setPutIndex(_tok0.getIndex());
- _tok1.setPutIndex(_tok1.getIndex());
- _multiLineValue=null;
- }
- _buffer.setMarkIndex(-1);
+ _handler.parsedHeader(header, value);
+ _tok0.setPutIndex(_tok0.getIndex());
+ _tok1.setPutIndex(_tok1.getIndex());
+ _multiLineValue=null;
+ }
+ _buffer.setMarkIndex(-1);
- // now handle ch
- if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED)
- {
- // work out the _content demarcation
- if (_contentLength == HttpTokens.UNKNOWN_CONTENT)
+ // now handle ch
+ if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED)
{
- if (_responseStatus == 0 // request
- || _responseStatus == 304 // not-modified response
- || _responseStatus == 204 // no-content response
- || _responseStatus < 200) // 1xx response
- _contentLength=HttpTokens.NO_CONTENT;
- else
- _contentLength=HttpTokens.EOF_CONTENT;
- }
+ // work out the _content demarcation
+ if (_contentLength == HttpTokens.UNKNOWN_CONTENT)
+ {
+ if (_responseStatus == 0 // request
+ || _responseStatus == 304 // not-modified response
+ || _responseStatus == 204 // no-content response
+ || _responseStatus < 200) // 1xx response
+ _contentLength=HttpTokens.NO_CONTENT;
+ else
+ _contentLength=HttpTokens.EOF_CONTENT;
+ }
- _contentPosition=0;
- _eol=ch;
- if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasContent() && _buffer.peek()==HttpTokens.LINE_FEED)
- _eol=_buffer.get();
+ _contentPosition=0;
+ _eol=ch;
+ if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasContent() && _buffer.peek()==HttpTokens.LINE_FEED)
+ _eol=_buffer.get();
- // We convert _contentLength to an int for this switch statement because
- // we don't care about the amount of data available just whether there is some.
- switch (_contentLength > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) _contentLength)
- {
- case HttpTokens.EOF_CONTENT:
- _state=STATE_EOF_CONTENT;
- _handler.headerComplete(); // May recurse here !
- break;
-
- case HttpTokens.CHUNKED_CONTENT:
- _state=STATE_CHUNKED_CONTENT;
- _handler.headerComplete(); // May recurse here !
- break;
-
- case HttpTokens.NO_CONTENT:
- _state=_persistent||(_responseStatus>=100&&_responseStatus<200)?STATE_END:STATE_SEEKING_EOF;
- _handler.headerComplete();
- _handler.messageComplete(_contentPosition);
- break;
-
- default:
- _state=STATE_CONTENT;
- _handler.headerComplete(); // May recurse here !
- break;
- }
- return 1;
- }
- else
- {
- // New header
- _length=1;
- _buffer.mark();
- _state=STATE_HEADER_NAME;
+ // We convert _contentLength to an int for this switch statement because
+ // we don't care about the amount of data available just whether there is some.
+ switch (_contentLength > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) _contentLength)
+ {
+ case HttpTokens.EOF_CONTENT:
+ _state=STATE_EOF_CONTENT;
+ _handler.headerComplete(); // May recurse here !
+ break;
+
+ case HttpTokens.CHUNKED_CONTENT:
+ _state=STATE_CHUNKED_CONTENT;
+ _handler.headerComplete(); // May recurse here !
+ break;
+
+ case HttpTokens.NO_CONTENT:
+ _handler.headerComplete();
+ _state=_persistent||(_responseStatus>=100&&_responseStatus<200)?STATE_END:STATE_SEEKING_EOF;
+ _handler.messageComplete(_contentPosition);
+ break;
- // try cached name!
- if (array!=null)
+ default:
+ _state=STATE_CONTENT;
+ _handler.headerComplete(); // May recurse here !
+ break;
+ }
+ return 1;
+ }
+ else
{
- _cached=HttpHeaders.CACHE.getBest(array, _buffer.markIndex(), length+1);
+ // New header
+ _length=1;
+ _buffer.mark();
+ _state=STATE_HEADER_NAME;
- if (_cached!=null)
+ // try cached name!
+ if (array!=null)
{
- _length=_cached.length();
- _buffer.setGetIndex(_buffer.markIndex()+_length);
- length=_buffer.length();
+ _cached=HttpHeaders.CACHE.getBest(array, _buffer.markIndex(), length+1);
+
+ if (_cached!=null)
+ {
+ _length=_cached.length();
+ _buffer.setGetIndex(_buffer.markIndex()+_length);
+ length=_buffer.length();
+ }
}
}
}
}
- }
- break;
+ break;
- case STATE_HEADER_NAME:
- switch(ch)
- {
- case HttpTokens.CARRIAGE_RETURN:
- case HttpTokens.LINE_FEED:
- if (_length > 0)
- _tok0.update(_buffer.markIndex(), _buffer.markIndex() + _length);
- _eol=ch;
- _state=STATE_HEADER;
- break;
- case HttpTokens.COLON:
- if (_length > 0 && _cached==null)
- _tok0.update(_buffer.markIndex(), _buffer.markIndex() + _length);
- _length=-1;
- _state=STATE_HEADER_VALUE;
- break;
- case HttpTokens.SPACE:
- case HttpTokens.TAB:
- break;
- default:
+ case STATE_HEADER_NAME:
+ switch(ch)
{
- _cached=null;
- if (_length == -1)
- _buffer.mark();
- _length=_buffer.getIndex() - _buffer.markIndex();
- _state=STATE_HEADER_IN_NAME;
+ case HttpTokens.CARRIAGE_RETURN:
+ case HttpTokens.LINE_FEED:
+ if (_length > 0)
+ _tok0.update(_buffer.markIndex(), _buffer.markIndex() + _length);
+ _eol=ch;
+ _state=STATE_HEADER;
+ break;
+ case HttpTokens.COLON:
+ if (_length > 0 && _cached==null)
+ _tok0.update(_buffer.markIndex(), _buffer.markIndex() + _length);
+ _length=-1;
+ _state=STATE_HEADER_VALUE;
+ break;
+ case HttpTokens.SPACE:
+ case HttpTokens.TAB:
+ break;
+ default:
+ {
+ _cached=null;
+ if (_length == -1)
+ _buffer.mark();
+ _length=_buffer.getIndex() - _buffer.markIndex();
+ _state=STATE_HEADER_IN_NAME;
+ }
}
- }
- break;
+ break;
- case STATE_HEADER_IN_NAME:
- switch(ch)
- {
- case HttpTokens.CARRIAGE_RETURN:
- case HttpTokens.LINE_FEED:
- if (_length > 0)
- _tok0.update(_buffer.markIndex(), _buffer.markIndex() + _length);
- _eol=ch;
- _state=STATE_HEADER;
- break;
- case HttpTokens.COLON:
- if (_length > 0 && _cached==null)
- _tok0.update(_buffer.markIndex(), _buffer.markIndex() + _length);
- _length=-1;
- _state=STATE_HEADER_VALUE;
- break;
- case HttpTokens.SPACE:
- case HttpTokens.TAB:
- _state=STATE_HEADER_NAME;
- break;
- default:
+ case STATE_HEADER_IN_NAME:
+ switch(ch)
{
- _cached=null;
- _length++;
+ case HttpTokens.CARRIAGE_RETURN:
+ case HttpTokens.LINE_FEED:
+ if (_length > 0)
+ _tok0.update(_buffer.markIndex(), _buffer.markIndex() + _length);
+ _eol=ch;
+ _state=STATE_HEADER;
+ break;
+ case HttpTokens.COLON:
+ if (_length > 0 && _cached==null)
+ _tok0.update(_buffer.markIndex(), _buffer.markIndex() + _length);
+ _length=-1;
+ _state=STATE_HEADER_VALUE;
+ break;
+ case HttpTokens.SPACE:
+ case HttpTokens.TAB:
+ _state=STATE_HEADER_NAME;
+ break;
+ default:
+ {
+ _cached=null;
+ _length++;
+ }
}
- }
- break;
+ break;
- case STATE_HEADER_VALUE:
- switch(ch)
- {
- case HttpTokens.CARRIAGE_RETURN:
- case HttpTokens.LINE_FEED:
- if (_length > 0)
- {
- if (_tok1.length() == 0)
- _tok1.update(_buffer.markIndex(), _buffer.markIndex() + _length);
- else
+ case STATE_HEADER_VALUE:
+ switch(ch)
+ {
+ case HttpTokens.CARRIAGE_RETURN:
+ case HttpTokens.LINE_FEED:
+ if (_length > 0)
{
- // Continuation line!
- if (_multiLineValue == null) _multiLineValue=_tok1.toString(StringUtil.__ISO_8859_1);
- _tok1.update(_buffer.markIndex(), _buffer.markIndex() + _length);
- _multiLineValue += " " + _tok1.toString(StringUtil.__ISO_8859_1);
+ if (_tok1.length() == 0)
+ _tok1.update(_buffer.markIndex(), _buffer.markIndex() + _length);
+ else
+ {
+ // Continuation line!
+ if (_multiLineValue == null) _multiLineValue=_tok1.toString(StringUtil.__ISO_8859_1);
+ _tok1.update(_buffer.markIndex(), _buffer.markIndex() + _length);
+ _multiLineValue += " " + _tok1.toString(StringUtil.__ISO_8859_1);
+ }
}
+ _eol=ch;
+ _state=STATE_HEADER;
+ break;
+ case HttpTokens.SPACE:
+ case HttpTokens.TAB:
+ break;
+ default:
+ {
+ if (_length == -1)
+ _buffer.mark();
+ _length=_buffer.getIndex() - _buffer.markIndex();
+ _state=STATE_HEADER_IN_VALUE;
}
- _eol=ch;
- _state=STATE_HEADER;
- break;
- case HttpTokens.SPACE:
- case HttpTokens.TAB:
- break;
- default:
- {
- if (_length == -1)
- _buffer.mark();
- _length=_buffer.getIndex() - _buffer.markIndex();
- _state=STATE_HEADER_IN_VALUE;
}
- }
- break;
+ break;
- case STATE_HEADER_IN_VALUE:
- switch(ch)
- {
- case HttpTokens.CARRIAGE_RETURN:
- case HttpTokens.LINE_FEED:
- if (_length > 0)
- {
- if (_tok1.length() == 0)
- _tok1.update(_buffer.markIndex(), _buffer.markIndex() + _length);
- else
+ case STATE_HEADER_IN_VALUE:
+ switch(ch)
+ {
+ case HttpTokens.CARRIAGE_RETURN:
+ case HttpTokens.LINE_FEED:
+ if (_length > 0)
{
- // Continuation line!
- if (_multiLineValue == null) _multiLineValue=_tok1.toString(StringUtil.__ISO_8859_1);
- _tok1.update(_buffer.markIndex(), _buffer.markIndex() + _length);
- _multiLineValue += " " + _tok1.toString(StringUtil.__ISO_8859_1);
+ if (_tok1.length() == 0)
+ _tok1.update(_buffer.markIndex(), _buffer.markIndex() + _length);
+ else
+ {
+ // Continuation line!
+ if (_multiLineValue == null) _multiLineValue=_tok1.toString(StringUtil.__ISO_8859_1);
+ _tok1.update(_buffer.markIndex(), _buffer.markIndex() + _length);
+ _multiLineValue += " " + _tok1.toString(StringUtil.__ISO_8859_1);
+ }
}
- }
- _eol=ch;
- _state=STATE_HEADER;
- break;
- case HttpTokens.SPACE:
- case HttpTokens.TAB:
- _state=STATE_HEADER_VALUE;
- break;
- default:
- _length++;
- }
- break;
- }
- } // end of HEADER states loop
-
- // ==========================
-
- // Handle HEAD response
- if (_responseStatus>0 && _headResponse)
- {
- _state=_persistent||(_responseStatus>=100&&_responseStatus<200)?STATE_END:STATE_SEEKING_EOF;
- _handler.messageComplete(_contentLength);
- }
-
+ _eol=ch;
+ _state=STATE_HEADER;
+ break;
+ case HttpTokens.SPACE:
+ case HttpTokens.TAB:
+ _state=STATE_HEADER_VALUE;
+ break;
+ default:
+ _length++;
+ }
+ break;
+ }
+ } // end of HEADER states loop
- // ==========================
+ // ==========================
- // Handle _content
- length=_buffer.length();
- Buffer chunk;
- last=_state;
- while (_state > STATE_END && length > 0)
- {
- if (last!=_state)
+ // Handle HEAD response
+ if (_responseStatus>0 && _headResponse)
{
- progress++;
- last=_state;
+ _state=_persistent||(_responseStatus>=100&&_responseStatus<200)?STATE_END:STATE_SEEKING_EOF;
+ _handler.messageComplete(_contentLength);
}
- if (_eol == HttpTokens.CARRIAGE_RETURN && _buffer.peek() == HttpTokens.LINE_FEED)
- {
- _eol=_buffer.get();
- length=_buffer.length();
- continue;
- }
- _eol=0;
- switch (_state)
+
+ // ==========================
+
+ // Handle _content
+ length=_buffer.length();
+ Buffer chunk;
+ last=_state;
+ while (_state > STATE_END && length > 0)
{
- case STATE_EOF_CONTENT:
- chunk=_buffer.get(_buffer.length());
- _contentPosition += chunk.length();
- _contentView.update(chunk);
- _handler.content(chunk); // May recurse here
- // TODO adjust the _buffer to keep unconsumed content
- return 1;
-
- case STATE_CONTENT:
+ if (last!=_state)
{
- long remaining=_contentLength - _contentPosition;
- if (remaining == 0)
- {
- _state=_persistent?STATE_END:STATE_SEEKING_EOF;
- _handler.messageComplete(_contentPosition);
+ progress++;
+ last=_state;
+ }
+
+ if (_eol == HttpTokens.CARRIAGE_RETURN && _buffer.peek() == HttpTokens.LINE_FEED)
+ {
+ _eol=_buffer.get();
+ length=_buffer.length();
+ continue;
+ }
+ _eol=0;
+ switch (_state)
+ {
+ case STATE_EOF_CONTENT:
+ chunk=_buffer.get(_buffer.length());
+ _contentPosition += chunk.length();
+ _contentView.update(chunk);
+ _handler.content(chunk); // May recurse here
+ // TODO adjust the _buffer to keep unconsumed content
return 1;
- }
- if (length > remaining)
+ case STATE_CONTENT:
{
- // We can cast reamining to an int as we know that it is smaller than
- // or equal to length which is already an int.
- length=(int)remaining;
- }
+ long remaining=_contentLength - _contentPosition;
+ if (remaining == 0)
+ {
+ _state=_persistent?STATE_END:STATE_SEEKING_EOF;
+ _handler.messageComplete(_contentPosition);
+ return 1;
+ }
- chunk=_buffer.get(length);
- _contentPosition += chunk.length();
- _contentView.update(chunk);
- _handler.content(chunk); // May recurse here
+ if (length > remaining)
+ {
+ // We can cast reamining to an int as we know that it is smaller than
+ // or equal to length which is already an int.
+ length=(int)remaining;
+ }
- if(_contentPosition == _contentLength)
- {
- _state=_persistent?STATE_END:STATE_SEEKING_EOF;
- _handler.messageComplete(_contentPosition);
+ chunk=_buffer.get(length);
+ _contentPosition += chunk.length();
+ _contentView.update(chunk);
+ _handler.content(chunk); // May recurse here
+
+ if(_contentPosition == _contentLength)
+ {
+ _state=_persistent?STATE_END:STATE_SEEKING_EOF;
+ _handler.messageComplete(_contentPosition);
+ }
+ // TODO adjust the _buffer to keep unconsumed content
+ return 1;
}
- // TODO adjust the _buffer to keep unconsumed content
- return 1;
- }
- case STATE_CHUNKED_CONTENT:
- {
- ch=_buffer.peek();
- if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED)
- _eol=_buffer.get();
- else if (ch <= HttpTokens.SPACE)
- _buffer.get();
- else
+ case STATE_CHUNKED_CONTENT:
{
- _chunkLength=0;
- _chunkPosition=0;
- _state=STATE_CHUNK_SIZE;
+ ch=_buffer.peek();
+ if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED)
+ _eol=_buffer.get();
+ else if (ch <= HttpTokens.SPACE)
+ _buffer.get();
+ else
+ {
+ _chunkLength=0;
+ _chunkPosition=0;
+ _state=STATE_CHUNK_SIZE;
+ }
+ break;
}
- break;
- }
- case STATE_CHUNK_SIZE:
- {
- ch=_buffer.get();
- if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED)
+ case STATE_CHUNK_SIZE:
{
- _eol=ch;
-
- if (_chunkLength == 0)
+ ch=_buffer.get();
+ if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED)
{
- if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasContent() && _buffer.peek()==HttpTokens.LINE_FEED)
- _eol=_buffer.get();
- _state=_persistent?STATE_END:STATE_SEEKING_EOF;
- _handler.messageComplete(_contentPosition);
- return 1;
+ _eol=ch;
+
+ if (_chunkLength == 0)
+ {
+ if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasContent() && _buffer.peek()==HttpTokens.LINE_FEED)
+ _eol=_buffer.get();
+ _state=_persistent?STATE_END:STATE_SEEKING_EOF;
+ _handler.messageComplete(_contentPosition);
+ return 1;
+ }
+ else
+ _state=STATE_CHUNK;
}
+ else if (ch <= HttpTokens.SPACE || ch == HttpTokens.SEMI_COLON)
+ _state=STATE_CHUNK_PARAMS;
+ else if (ch >= '0' && ch <= '9')
+ _chunkLength=_chunkLength * 16 + (ch - '0');
+ else if (ch >= 'a' && ch <= 'f')
+ _chunkLength=_chunkLength * 16 + (10 + ch - 'a');
+ else if (ch >= 'A' && ch <= 'F')
+ _chunkLength=_chunkLength * 16 + (10 + ch - 'A');
else
- _state=STATE_CHUNK;
+ throw new IOException("bad chunk char: " + ch);
+ break;
}
- else if (ch <= HttpTokens.SPACE || ch == HttpTokens.SEMI_COLON)
- _state=STATE_CHUNK_PARAMS;
- else if (ch >= '0' && ch <= '9')
- _chunkLength=_chunkLength * 16 + (ch - '0');
- else if (ch >= 'a' && ch <= 'f')
- _chunkLength=_chunkLength * 16 + (10 + ch - 'a');
- else if (ch >= 'A' && ch <= 'F')
- _chunkLength=_chunkLength * 16 + (10 + ch - 'A');
- else
- throw new IOException("bad chunk char: " + ch);
- break;
- }
- case STATE_CHUNK_PARAMS:
- {
- ch=_buffer.get();
- if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED)
+ case STATE_CHUNK_PARAMS:
{
- _eol=ch;
- if (_chunkLength == 0)
+ ch=_buffer.get();
+ if (ch == HttpTokens.CARRIAGE_RETURN || ch == HttpTokens.LINE_FEED)
{
- if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasContent() && _buffer.peek()==HttpTokens.LINE_FEED)
- _eol=_buffer.get();
- _state=_persistent?STATE_END:STATE_SEEKING_EOF;
- _handler.messageComplete(_contentPosition);
- return 1;
+ _eol=ch;
+ if (_chunkLength == 0)
+ {
+ if (_eol==HttpTokens.CARRIAGE_RETURN && _buffer.hasContent() && _buffer.peek()==HttpTokens.LINE_FEED)
+ _eol=_buffer.get();
+ _state=_persistent?STATE_END:STATE_SEEKING_EOF;
+ _handler.messageComplete(_contentPosition);
+ return 1;
+ }
+ else
+ _state=STATE_CHUNK;
}
- else
- _state=STATE_CHUNK;
+ break;
}
- break;
- }
- case STATE_CHUNK:
- {
- int remaining=_chunkLength - _chunkPosition;
- if (remaining == 0)
+ case STATE_CHUNK:
+ {
+ int remaining=_chunkLength - _chunkPosition;
+ if (remaining == 0)
+ {
+ _state=STATE_CHUNKED_CONTENT;
+ break;
+ }
+ else if (length > remaining)
+ length=remaining;
+ chunk=_buffer.get(length);
+ _contentPosition += chunk.length();
+ _chunkPosition += chunk.length();
+ _contentView.update(chunk);
+ _handler.content(chunk); // May recurse here
+ // TODO adjust the _buffer to keep unconsumed content
+ return 1;
+ }
+
+ case STATE_SEEKING_EOF:
{
- _state=STATE_CHUNKED_CONTENT;
+ // Skip all data
+ _buffer.clear();
break;
}
- else if (length > remaining)
- length=remaining;
- chunk=_buffer.get(length);
- _contentPosition += chunk.length();
- _chunkPosition += chunk.length();
- _contentView.update(chunk);
- _handler.content(chunk); // May recurse here
- // TODO adjust the _buffer to keep unconsumed content
- return 1;
- }
-
- case STATE_SEEKING_EOF:
- {
- // Skip all data
- _buffer.clear();
- break;
}
+
+ length=_buffer.length();
}
- length=_buffer.length();
+ return progress;
+ }
+ finally
+ {
+ _lock.unlock();
}
-
- return progress;
}
/* ------------------------------------------------------------------------------- */
/** fill the buffers from the endpoint
*
*/
- public long fill() throws IOException
+ protected int fill() throws IOException
{
// Do we have a buffer?
if (_buffer==null)
@@ -1006,7 +1018,10 @@ public class HttpParser implements Parser
// Are we full?
if (_buffer.space() == 0)
+ {
+ LOG.warn("Full {}",_buffer.toDetailString());
throw new HttpException(HttpStatus.REQUEST_ENTITY_TOO_LARGE_413, "FULL "+(_buffer==_body?"body":"head"));
+ }
try
{
@@ -1023,104 +1038,87 @@ public class HttpParser implements Parser
}
/* ------------------------------------------------------------------------------- */
- /** Skip any CRLFs in buffers
- *
- */
- public void skipCRLF()
+ public void reset()
{
-
- while (_header!=null && _header.length()>0)
+ _lock.lock();
+ try
{
- byte ch = _header.peek();
- if (ch==HttpTokens.CARRIAGE_RETURN || ch==HttpTokens.LINE_FEED)
- {
- _eol=ch;
- _header.skip(1);
- }
- else
- break;
- }
+ // reset state
+ _contentView.setGetIndex(_contentView.putIndex());
+ _state=_persistent?STATE_START:(_endp.isInputShutdown()?STATE_END:STATE_SEEKING_EOF);
+ _contentLength=HttpTokens.UNKNOWN_CONTENT;
+ _contentPosition=0;
+ _length=0;
+ _responseStatus=0;
+
+ // Consume LF if CRLF
+ if (_eol == HttpTokens.CARRIAGE_RETURN && _buffer!=null && _buffer.hasContent() && _buffer.peek() == HttpTokens.LINE_FEED)
+ _eol=_buffer.get();
- while (_body!=null && _body.length()>0)
- {
- byte ch = _body.peek();
- if (ch==HttpTokens.CARRIAGE_RETURN || ch==HttpTokens.LINE_FEED)
+ if (_body!=null && _body.hasContent())
{
- _eol=ch;
- _body.skip(1);
+ // There is content in the body after the end of the request.
+ // This is probably a pipelined header of the next request, so we need to
+ // copy it to the header buffer.
+ if (_header==null)
+ {
+ _header=_buffers.getHeader();
+ }
+ else
+ {
+ _header.setMarkIndex(-1);
+ _header.compact();
+ }
+ int take=_header.space();
+ if (take>_body.length())
+ take=_body.length();
+ _body.peek(_body.getIndex(),take);
+ _body.skip(_header.put(_body.peek(_body.getIndex(),take)));
}
- else
- break;
- }
-
- }
-
- /* ------------------------------------------------------------------------------- */
- public void reset()
- {
- // reset state
- _contentView.setGetIndex(_contentView.putIndex());
- _state=_persistent?STATE_START:(_endp.isInputShutdown()?STATE_END:STATE_SEEKING_EOF);
- _contentLength=HttpTokens.UNKNOWN_CONTENT;
- _contentPosition=0;
- _length=0;
- _responseStatus=0;
-
- // Consume LF if CRLF
- if (_eol == HttpTokens.CARRIAGE_RETURN && _buffer!=null && _buffer.hasContent() && _buffer.peek() == HttpTokens.LINE_FEED)
- _eol=_buffer.get();
- if (_body!=null && _body.hasContent())
- {
- // There is content in the body after the end of the request.
- // This is probably a pipelined header of the next request, so we need to
- // copy it to the header buffer.
- if (_header==null)
- {
- _header=_buffers.getHeader();
- }
- else
+ if (_header!=null)
{
_header.setMarkIndex(-1);
_header.compact();
}
- int take=_header.space();
- if (take>_body.length())
- take=_body.length();
- _body.peek(_body.getIndex(),take);
- _body.skip(_header.put(_body.peek(_body.getIndex(),take)));
- }
+ if (_body!=null)
+ _body.setMarkIndex(-1);
- if (_header!=null)
+ _buffer=_header;
+ }
+ finally
{
- _header.setMarkIndex(-1);
- _header.compact();
+ _lock.unlock();
}
- if (_body!=null)
- _body.setMarkIndex(-1);
-
- _buffer=_header;
}
/* ------------------------------------------------------------------------------- */
public void returnBuffers()
{
- if (_body!=null && !_body.hasContent() && _body.markIndex()==-1 && _buffers!=null)
+ _lock.lock();
+ try
{
- if (_buffer==_body)
- _buffer=_header;
- if (_buffers!=null)
- _buffers.returnBuffer(_body);
- _body=null;
- }
+ if (_body!=null && !_body.hasContent() && _body.markIndex()==-1 && _buffers!=null)
+ {
+ if (_buffer==_body)
+ _buffer=_header;
+ if (_buffers!=null)
+ _buffers.returnBuffer(_body);
+ _body=null;
+ }
- if (_header!=null && !_header.hasContent() && _header.markIndex()==-1 && _buffers!=null)
+ if (_header!=null && !_header.hasContent() && _header.markIndex()==-1 && _buffers!=null)
+ {
+ if (_buffer==_header)
+ _buffer=null;
+ _buffers.returnBuffer(_header);
+ _header=null;
+ }
+ }
+ finally
{
- if (_buffer==_header)
- _buffer=null;
- _buffers.returnBuffer(_header);
- _header=null;
+ _lock.unlock();
}
}
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/AsyncEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/AsyncEndPoint.java
index 330f6828ab..fd72e347d6 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/AsyncEndPoint.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/AsyncEndPoint.java
@@ -22,12 +22,6 @@ public interface AsyncEndPoint extends EndPoint
*/
public void asyncDispatch();
- /**
- * @return true if this endpoint can accept a dispatch. False if the
- * endpoint cannot accept a dispatched (eg is suspended or already dispatched)
- */
- public boolean isReadyForDispatch();
-
/* ------------------------------------------------------------ */
/** Schedule a write dispatch.
* Set the endpoint to not be writable and schedule a dispatch when
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/EofException.java b/jetty-io/src/main/java/org/eclipse/jetty/io/EofException.java
index 9c864aa078..03369e5a79 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/EofException.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/EofException.java
@@ -15,6 +15,13 @@ package org.eclipse.jetty.io;
import java.io.EOFException;
+
+/* ------------------------------------------------------------ */
+/** A Jetty specialization of EOFException.
+ * <p> This is thrown by Jetty to distinguish between EOF received from
+ * the connection, vs and EOF thrown by some application talking to some other file/socket etc.
+ * The only difference in handling is that Jetty EOFs are logged less verbosely.
+ */
public class EofException extends EOFException
{
public EofException()
diff --git a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java
index e134379c80..31660996c0 100644
--- a/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java
+++ b/jetty-io/src/main/java/org/eclipse/jetty/io/nio/SelectChannelEndPoint.java
@@ -168,14 +168,6 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
return;
}
- // Otherwise if we are still dispatched
- if (!isReadyForDispatch())
- {
- // we are not interested in further selecting
- _key.interestOps(0);
- return;
- }
-
// Remove writeable op
if ((_key.readyOps() & SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE && (_key.interestOps() & SelectionKey.OP_WRITE) == SelectionKey.OP_WRITE)
{
@@ -337,16 +329,6 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
}
/* ------------------------------------------------------------ */
- public boolean isReadyForDispatch()
- {
- synchronized (this)
- {
- // Ready if not dispatched and not suspended
- return !(_dispatched || getConnection().isSuspended());
- }
- }
-
- /* ------------------------------------------------------------ */
/*
* Allows thread to block waiting for further events.
*/
@@ -467,9 +449,11 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
{
if (getChannel().isOpen())
{
+ boolean read_interest = _readBlocked || (!_dispatched && !_connection.isSuspended());
+ boolean write_interest= _writeBlocked || (!_dispatched && !_writable);
_interestOps =
- ((!_socket.isInputShutdown() && (!_dispatched || _readBlocked)) ? SelectionKey.OP_READ : 0)
- | ((!_socket.isOutputShutdown()&& (!_writable || _writeBlocked)) ? SelectionKey.OP_WRITE : 0);
+ ((!_socket.isInputShutdown() && read_interest ) ? SelectionKey.OP_READ : 0)
+ | ((!_socket.isOutputShutdown()&& write_interest) ? SelectionKey.OP_WRITE : 0);
try
{
current_ops = ((_key!=null && _key.isValid())?_key.interestOps():-1);
@@ -488,6 +472,7 @@ public class SelectChannelEndPoint extends ChannelEndPoint implements AsyncEndPo
_selectSet.wakeup();
}
}
+
/* ------------------------------------------------------------ */
/**
diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/ConstraintSecurityHandler.java b/jetty-security/src/main/java/org/eclipse/jetty/security/ConstraintSecurityHandler.java
index f8d92e8d27..76ca4ee469 100644
--- a/jetty-security/src/main/java/org/eclipse/jetty/security/ConstraintSecurityHandler.java
+++ b/jetty-security/src/main/java/org/eclipse/jetty/security/ConstraintSecurityHandler.java
@@ -27,7 +27,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
import org.eclipse.jetty.http.PathMap;
import org.eclipse.jetty.http.security.Constraint;
import org.eclipse.jetty.server.Connector;
-import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.AbstractHttpConnection;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Response;
import org.eclipse.jetty.server.UserIdentity;
@@ -351,7 +351,7 @@ public class ConstraintSecurityHandler extends SecurityHandler implements Constr
{
return true;
}
- HttpConnection connection = HttpConnection.getCurrentConnection();
+ AbstractHttpConnection connection = AbstractHttpConnection.getCurrentConnection();
Connector connector = connection.getConnector();
if (dataConstraint == UserDataConstraint.Integral)
diff --git a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/FormAuthenticator.java b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/FormAuthenticator.java
index b27c2ec543..e2710baa16 100644
--- a/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/FormAuthenticator.java
+++ b/jetty-security/src/main/java/org/eclipse/jetty/security/authentication/FormAuthenticator.java
@@ -35,7 +35,7 @@ import org.eclipse.jetty.security.ServerAuthException;
import org.eclipse.jetty.security.UserAuthentication;
import org.eclipse.jetty.server.Authentication;
import org.eclipse.jetty.server.Authentication.User;
-import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.AbstractHttpConnection;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.UserIdentity;
import org.eclipse.jetty.util.MultiMap;
@@ -259,7 +259,7 @@ public class FormAuthenticator extends LoginAuthenticator
// so restore method and parameters
session.removeAttribute(__J_POST);
- Request base_request = (req instanceof Request)?(Request)req:HttpConnection.getCurrentConnection().getRequest();
+ Request base_request = (req instanceof Request)?(Request)req:AbstractHttpConnection.getCurrentConnection().getRequest();
base_request.setMethod(HttpMethods.POST);
base_request.setParameters(j_post);
}
@@ -289,7 +289,7 @@ public class FormAuthenticator extends LoginAuthenticator
if (MimeTypes.FORM_ENCODED.equalsIgnoreCase(req.getContentType()) && HttpMethods.POST.equals(request.getMethod()))
{
- Request base_request = (req instanceof Request)?(Request)req:HttpConnection.getCurrentConnection().getRequest();
+ Request base_request = (req instanceof Request)?(Request)req:AbstractHttpConnection.getCurrentConnection().getRequest();
base_request.extractParameters();
session.setAttribute(__J_POST, new MultiMap<String>(base_request.getParameters()));
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java
index 199d0e18e2..6a54fa3a69 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractConnector.java
@@ -1039,7 +1039,7 @@ public abstract class AbstractConnector extends HttpBuffers implements Connector
/* ------------------------------------------------------------ */
protected void connectionUpgraded(Connection oldConnection, Connection newConnection)
{
- _requestStats.set((oldConnection instanceof HttpConnection)?((HttpConnection)oldConnection).getRequests():0);
+ _requestStats.set((oldConnection instanceof AbstractHttpConnection)?((AbstractHttpConnection)oldConnection).getRequests():0);
}
/* ------------------------------------------------------------ */
@@ -1051,7 +1051,7 @@ public abstract class AbstractConnector extends HttpBuffers implements Connector
return;
long duration = System.currentTimeMillis() - connection.getTimeStamp();
- int requests = (connection instanceof HttpConnection)?((HttpConnection)connection).getRequests():0;
+ int requests = (connection instanceof AbstractHttpConnection)?((AbstractHttpConnection)connection).getRequests():0;
_requestStats.set(requests);
_connectionStats.decrement();
_connectionDurationStats.set(duration);
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java
index 2fed73903a..4a7d895b62 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpConnection.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AbstractHttpConnection.java
@@ -88,12 +88,12 @@ import org.eclipse.jetty.util.thread.Timeout;
* </p>
*
*/
-public abstract class HttpConnection extends AbstractConnection
+public abstract class AbstractHttpConnection extends AbstractConnection
{
- private static final Logger LOG = Log.getLogger(HttpConnection.class);
+ private static final Logger LOG = Log.getLogger(AbstractHttpConnection.class);
private static final int UNKNOWN = -2;
- private static final ThreadLocal<HttpConnection> __currentConnection = new ThreadLocal<HttpConnection>();
+ private static final ThreadLocal<AbstractHttpConnection> __currentConnection = new ThreadLocal<AbstractHttpConnection>();
private int _requests;
@@ -127,13 +127,13 @@ public abstract class HttpConnection extends AbstractConnection
private boolean _delayedHandling=false;
/* ------------------------------------------------------------ */
- public static HttpConnection getCurrentConnection()
+ public static AbstractHttpConnection getCurrentConnection()
{
return __currentConnection.get();
}
/* ------------------------------------------------------------ */
- protected static void setCurrentConnection(HttpConnection connection)
+ protected static void setCurrentConnection(AbstractHttpConnection connection)
{
__currentConnection.set(connection);
}
@@ -142,7 +142,7 @@ public abstract class HttpConnection extends AbstractConnection
/** Constructor
*
*/
- public HttpConnection(Connector connector, EndPoint endpoint, Server server)
+ public AbstractHttpConnection(Connector connector, EndPoint endpoint, Server server)
{
super(endpoint);
_uri = StringUtil.__UTF8.equals(URIUtil.__CHARSET)?new HttpURI():new EncodedHttpURI(URIUtil.__CHARSET);
@@ -159,7 +159,7 @@ public abstract class HttpConnection extends AbstractConnection
}
/* ------------------------------------------------------------ */
- protected HttpConnection(Connector connector, EndPoint endpoint, Server server,
+ protected AbstractHttpConnection(Connector connector, EndPoint endpoint, Server server,
Parser parser, Generator generator, Request request)
{
super(endpoint);
@@ -326,7 +326,7 @@ public abstract class HttpConnection extends AbstractConnection
}
if (_in == null)
- _in = new HttpInput(HttpConnection.this);
+ _in = new HttpInput(AbstractHttpConnection.this);
return _in;
}
@@ -841,6 +841,12 @@ public abstract class HttpConnection extends AbstractConnection
_responseFields.add(HttpHeaders.CONNECTION_BUFFER,HttpHeaderValues.KEEP_ALIVE_BUFFER);
_generator.setPersistent(true);
}
+ else if (HttpMethods.CONNECT.equals(_request.getMethod()))
+ {
+ _generator.setPersistent(true);
+ _parser.setPersistent(true);
+ }
+
if (_server.getSendDateHeader())
_generator.setDate(_request.getTimeStampBuffer());
break;
@@ -943,7 +949,7 @@ public abstract class HttpConnection extends AbstractConnection
{
Output()
{
- super(HttpConnection.this);
+ super(AbstractHttpConnection.this);
}
/* ------------------------------------------------------------ */
@@ -1113,7 +1119,7 @@ public abstract class HttpConnection extends AbstractConnection
{
OutputWriter()
{
- super(HttpConnection.this._out);
+ super(AbstractHttpConnection.this._out);
}
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java
index 55c7248b73..12ef54fdad 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncContinuation.java
@@ -69,7 +69,7 @@ public class AsyncContinuation implements AsyncContext, Continuation
/* ------------------------------------------------------------ */
- protected HttpConnection _connection;
+ protected AbstractHttpConnection _connection;
private List<ContinuationListener> _continuationListeners;
/* ------------------------------------------------------------ */
@@ -90,7 +90,7 @@ public class AsyncContinuation implements AsyncContext, Continuation
}
/* ------------------------------------------------------------ */
- protected void setConnection(final HttpConnection connection)
+ protected void setConnection(final AbstractHttpConnection connection)
{
synchronized(this)
{
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java
index 518dd0a1f3..99addd1c9b 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/AsyncHttpConnection.java
@@ -11,7 +11,7 @@ import org.eclipse.jetty.io.nio.SelectChannelEndPoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
-public class AsyncHttpConnection extends HttpConnection implements AsyncConnection
+public class AsyncHttpConnection extends AbstractHttpConnection implements AsyncConnection
{
private final static int NO_PROGRESS_INFO = Integer.getInteger("org.mortbay.jetty.NO_PROGRESS_INFO",100);
private final static int NO_PROGRESS_CLOSE = Integer.getInteger("org.mortbay.jetty.NO_PROGRESS_CLOSE",200);
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/BlockingHttpConnection.java b/jetty-server/src/main/java/org/eclipse/jetty/server/BlockingHttpConnection.java
index b8727c8cec..c73e597f5b 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/BlockingHttpConnection.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/BlockingHttpConnection.java
@@ -11,7 +11,7 @@ import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
-public class BlockingHttpConnection extends HttpConnection
+public class BlockingHttpConnection extends AbstractHttpConnection
{
private static final Logger LOG = Log.getLogger(BlockingHttpConnection.class);
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java
index 5422cb2662..99c9ec3312 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Dispatcher.java
@@ -130,7 +130,7 @@ public class Dispatcher implements RequestDispatcher
*/
public void include(ServletRequest request, ServletResponse response) throws ServletException, IOException
{
- Request baseRequest=(request instanceof Request)?((Request)request):HttpConnection.getCurrentConnection().getRequest();
+ Request baseRequest=(request instanceof Request)?((Request)request):AbstractHttpConnection.getCurrentConnection().getRequest();
request.removeAttribute(__JSP_FILE); // TODO remove when glassfish 1044 is fixed
if (!(request instanceof HttpServletRequest))
@@ -211,7 +211,7 @@ public class Dispatcher implements RequestDispatcher
*/
protected void forward(ServletRequest request, ServletResponse response, DispatcherType dispatch) throws ServletException, IOException
{
- Request baseRequest=(request instanceof Request)?((Request)request):HttpConnection.getCurrentConnection().getRequest();
+ Request baseRequest=(request instanceof Request)?((Request)request):AbstractHttpConnection.getCurrentConnection().getRequest();
Response base_response=baseRequest.getResponse();
response.resetBuffer();
base_response.fwdReset();
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Handler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Handler.java
index 519c8730c5..cf16c0b14a 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/Handler.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Handler.java
@@ -47,10 +47,10 @@ public interface Handler extends LifeCycle, Destroyable
* @param target The target of the request - either a URI or a name.
* @param baseRequest The original unwrapped request object.
* @param request The request either as the {@link Request}
- * object or a wrapper of that request. The {@link HttpConnection#getCurrentConnection()}
+ * object or a wrapper of that request. The {@link AbstractHttpConnection#getCurrentConnection()}
* method can be used access the Request object if required.
* @param response The response as the {@link Response}
- * object or a wrapper of that request. The {@link HttpConnection#getCurrentConnection()}
+ * object or a wrapper of that request. The {@link AbstractHttpConnection#getCurrentConnection()}
* method can be used access the Response object if required.
* @throws IOException
* @throws ServletException
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java
index 670fa95c81..abaec917d7 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpInput.java
@@ -22,11 +22,11 @@ import org.eclipse.jetty.io.Buffer;
public class HttpInput extends ServletInputStream
{
- protected final HttpConnection _connection;
+ protected final AbstractHttpConnection _connection;
protected final HttpParser _parser;
/* ------------------------------------------------------------ */
- public HttpInput(HttpConnection connection)
+ public HttpInput(AbstractHttpConnection connection)
{
_connection=connection;
_parser=(HttpParser)connection.getParser();
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java
index 6d59587785..7f5d2628b4 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java
@@ -36,7 +36,7 @@ import org.eclipse.jetty.util.ByteArrayOutputStream2;
*/
public class HttpOutput extends ServletOutputStream
{
- protected final HttpConnection _connection;
+ protected final AbstractHttpConnection _connection;
protected final AbstractGenerator _generator;
private boolean _closed;
@@ -47,7 +47,7 @@ public class HttpOutput extends ServletOutputStream
ByteArrayOutputStream2 _bytes;
/* ------------------------------------------------------------ */
- public HttpOutput(HttpConnection connection)
+ public HttpOutput(AbstractHttpConnection connection)
{
_connection=connection;
_generator=(AbstractGenerator)connection.getGenerator();
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java
index d4849acb12..4840351ba8 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/LocalConnector.java
@@ -116,7 +116,7 @@ public class LocalConnector extends AbstractConnector
};
endPoint.setGrowOutput(true);
- HttpConnection connection = new BlockingHttpConnection(LocalConnector.this, endPoint, getServer());
+ AbstractHttpConnection connection = new BlockingHttpConnection(LocalConnector.this, endPoint, getServer());
endPoint.setConnection(connection);
connectionOpened(connection);
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java
index 38f3b460d2..2cb95ca682 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Request.java
@@ -96,7 +96,7 @@ import org.eclipse.jetty.util.log.Logger;
* against the servlet URL patterns and {@link Request#setServletPath(String)} called as a result.</li>
* </ul>
*
- * A request instance is created for each {@link HttpConnection} accepted by the server
+ * A request instance is created for each {@link AbstractHttpConnection} accepted by the server
* and recycled for each HTTP request received via that connection. An effort is made
* to avoid reparsing headers and cookies that are likely to be the same for
* requests from the same connection.
@@ -116,7 +116,7 @@ public class Request implements HttpServletRequest
if (request instanceof Request)
return (Request) request;
- return HttpConnection.getCurrentConnection().getRequest();
+ return AbstractHttpConnection.getCurrentConnection().getRequest();
}
protected final AsyncContinuation _async = new AsyncContinuation();
private boolean _asyncSupported=true;
@@ -124,7 +124,7 @@ public class Request implements HttpServletRequest
private Authentication _authentication;
private MultiMap<String> _baseParameters;
private String _characterEncoding;
- protected HttpConnection _connection;
+ protected AbstractHttpConnection _connection;
private ContextHandler.Context _context;
private boolean _newContext;
private String _contextPath;
@@ -170,7 +170,7 @@ public class Request implements HttpServletRequest
}
/* ------------------------------------------------------------ */
- public Request(HttpConnection connection)
+ public Request(AbstractHttpConnection connection)
{
setConnection(connection);
}
@@ -382,7 +382,7 @@ public class Request implements HttpServletRequest
/**
* @return Returns the connection.
*/
- public HttpConnection getConnection()
+ public AbstractHttpConnection getConnection()
{
return _connection;
}
@@ -1466,7 +1466,7 @@ public class Request implements HttpServletRequest
{
try
{
- ((HttpConnection.Output)getServletResponse().getOutputStream()).sendContent(value);
+ ((AbstractHttpConnection.Output)getServletResponse().getOutputStream()).sendContent(value);
}
catch (IOException e)
{
@@ -1483,7 +1483,7 @@ public class Request implements HttpServletRequest
NIOBuffer buffer = byteBuffer.isDirect()
?new DirectNIOBuffer(byteBuffer,true)
:new IndirectNIOBuffer(byteBuffer,true);
- ((HttpConnection.Output)getServletResponse().getOutputStream()).sendResponse(buffer);
+ ((AbstractHttpConnection.Output)getServletResponse().getOutputStream()).sendResponse(buffer);
}
}
catch (IOException e)
@@ -1579,7 +1579,7 @@ public class Request implements HttpServletRequest
/* ------------------------------------------------------------ */
//final so we can safely call this from constructor
- protected final void setConnection(HttpConnection connection)
+ protected final void setConnection(AbstractHttpConnection connection)
{
_connection=connection;
_async.setConnection(connection);
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java
index fb6196a208..1cf9d3c71a 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Response.java
@@ -65,7 +65,7 @@ public class Response implements HttpServletResponse
*/
public final static String SET_INCLUDE_HEADER_PREFIX = "org.eclipse.jetty.server.include.";
- private final HttpConnection _connection;
+ private final AbstractHttpConnection _connection;
private int _status=SC_OK;
private String _reason;
private Locale _locale;
@@ -81,7 +81,7 @@ public class Response implements HttpServletResponse
/**
*
*/
- public Response(HttpConnection connection)
+ public Response(AbstractHttpConnection connection)
{
_connection=connection;
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java b/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java
index 10cfd69efa..e62fad56c7 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/Server.java
@@ -333,7 +333,7 @@ public class Server extends HandlerWrapper implements Attributes
* or after the entire request has been received (for short requests of known length), or
* on the dispatch of an async request.
*/
- public void handle(HttpConnection connection) throws IOException, ServletException
+ public void handle(AbstractHttpConnection connection) throws IOException, ServletException
{
final String target=connection.getRequest().getPathInfo();
final Request request=connection.getRequest();
@@ -355,7 +355,7 @@ public class Server extends HandlerWrapper implements Attributes
* or after the entire request has been received (for short requests of known length), or
* on the dispatch of an async request.
*/
- public void handleAsync(HttpConnection connection) throws IOException, ServletException
+ public void handleAsync(AbstractHttpConnection connection) throws IOException, ServletException
{
final AsyncContinuation async = connection.getRequest().getAsyncContinuation();
final AsyncContinuation.AsyncEventState state = async.getAsyncEventState();
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/bio/SocketConnector.java b/jetty-server/src/main/java/org/eclipse/jetty/server/bio/SocketConnector.java
index 9bff3cfa9a..6695a85807 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/bio/SocketConnector.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/bio/SocketConnector.java
@@ -31,7 +31,7 @@ import org.eclipse.jetty.io.EofException;
import org.eclipse.jetty.io.bio.SocketEndPoint;
import org.eclipse.jetty.server.AbstractConnector;
import org.eclipse.jetty.server.BlockingHttpConnection;
-import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.AbstractHttpConnection;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@@ -219,8 +219,8 @@ public class SocketConnector extends AbstractConnector
@Override
public void close() throws IOException
{
- if (_connection instanceof HttpConnection)
- ((HttpConnection)_connection).getRequest().getAsyncContinuation().cancel();
+ if (_connection instanceof AbstractHttpConnection)
+ ((AbstractHttpConnection)_connection).getRequest().getAsyncContinuation().cancel();
super.close();
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ConnectHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ConnectHandler.java
index efe75bef30..1e44f943e4 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ConnectHandler.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ConnectHandler.java
@@ -26,7 +26,7 @@ import org.eclipse.jetty.io.nio.IndirectNIOBuffer;
import org.eclipse.jetty.io.nio.SelectChannelEndPoint;
import org.eclipse.jetty.io.nio.SelectorManager;
import org.eclipse.jetty.server.Handler;
-import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.AbstractHttpConnection;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.HostMap;
@@ -232,7 +232,7 @@ public class ConnectHandler extends HandlerWrapper
// 1. when this unread data is written and the server replies before the clientToProxy
// connection is installed (it is only installed after returning from this method)
// 2. when the client sends data before this unread data has been written.
- HttpConnection httpConnection = HttpConnection.getCurrentConnection();
+ AbstractHttpConnection httpConnection = AbstractHttpConnection.getCurrentConnection();
Buffer headerBuffer = ((HttpParser)httpConnection.getParser()).getHeaderBuffer();
Buffer bodyBuffer = ((HttpParser)httpConnection.getParser()).getBodyBuffer();
int length = headerBuffer == null ? 0 : headerBuffer.length();
@@ -272,7 +272,7 @@ public class ConnectHandler extends HandlerWrapper
private ClientToProxyConnection prepareConnections(ConcurrentMap<String, Object> context, SocketChannel channel, Buffer buffer)
{
- HttpConnection httpConnection = HttpConnection.getCurrentConnection();
+ AbstractHttpConnection httpConnection = AbstractHttpConnection.getCurrentConnection();
ProxyToServerConnection proxyToServer = newProxyToServerConnection(context, buffer);
ClientToProxyConnection clientToProxy = newClientToProxyConnection(context, channel, httpConnection.getEndPoint(), httpConnection.getTimeStamp());
clientToProxy.setConnection(proxyToServer);
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java
index e6a0132b51..9a5a7b8420 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java
@@ -52,7 +52,7 @@ import org.eclipse.jetty.server.Dispatcher;
import org.eclipse.jetty.server.DispatcherType;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HandlerContainer;
-import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.AbstractHttpConnection;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.Attributes;
@@ -754,7 +754,7 @@ public class ContextHandler extends ScopedHandler implements Attributes, Server.
// Check the connector
if (_connectors != null && _connectors.size() > 0)
{
- String connector = HttpConnection.getCurrentConnection().getConnector().getName();
+ String connector = AbstractHttpConnection.getCurrentConnection().getConnector().getName();
if (connector == null || !_connectors.contains(connector))
return false;
}
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ErrorHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ErrorHandler.java
index 6a422e9be8..b43e34b9ce 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ErrorHandler.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ErrorHandler.java
@@ -23,7 +23,7 @@ import org.eclipse.jetty.http.HttpHeaders;
import org.eclipse.jetty.http.HttpMethods;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.MimeTypes;
-import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.AbstractHttpConnection;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.util.ByteArrayISO8859Writer;
@@ -45,7 +45,7 @@ public class ErrorHandler extends AbstractHandler
*/
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException
{
- HttpConnection connection = HttpConnection.getCurrentConnection();
+ AbstractHttpConnection connection = AbstractHttpConnection.getCurrentConnection();
connection.getRequest().setHandled(true);
String method = request.getMethod();
if(!method.equals(HttpMethods.GET) && !method.equals(HttpMethods.POST) && !method.equals(HttpMethods.HEAD))
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/IPAccessHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/IPAccessHandler.java
index 060e328832..4e6e50b52c 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/IPAccessHandler.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/IPAccessHandler.java
@@ -25,7 +25,7 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.http.HttpStatus;
import org.eclipse.jetty.http.PathMap;
import org.eclipse.jetty.io.EndPoint;
-import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.AbstractHttpConnection;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.util.IPAddressMap;
import org.eclipse.jetty.util.log.Log;
@@ -179,7 +179,7 @@ public class IPAccessHandler extends HandlerWrapper
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
// Get the real remote IP (not the one set by the forwarded headers (which may be forged))
- HttpConnection connection = baseRequest.getConnection();
+ AbstractHttpConnection connection = baseRequest.getConnection();
if (connection!=null)
{
EndPoint endp=connection.getEndPoint();
diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java
index 04a6ff9566..44ad95b29e 100644
--- a/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java
+++ b/jetty-server/src/main/java/org/eclipse/jetty/server/handler/ResourceHandler.java
@@ -30,7 +30,7 @@ import org.eclipse.jetty.io.Buffer;
import org.eclipse.jetty.io.ByteArrayBuffer;
import org.eclipse.jetty.io.WriterOutputStream;
import org.eclipse.jetty.server.Dispatcher;
-import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.AbstractHttpConnection;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Response;
import org.eclipse.jetty.server.handler.ContextHandler.Context;
@@ -432,10 +432,10 @@ public class ResourceHandler extends AbstractHandler
catch(IllegalStateException e) {out = new WriterOutputStream(response.getWriter());}
// See if a short direct method can be used?
- if (out instanceof HttpConnection.Output)
+ if (out instanceof AbstractHttpConnection.Output)
{
// TODO file mapped buffers
- ((HttpConnection.Output)out).sendContent(resource.getInputStream());
+ ((AbstractHttpConnection.Output)out).sendContent(resource.getInputStream());
}
else
{
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/AsyncUploadTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/AsyncRequestReadTest.java
index 1ea14c0fa1..736a7d64e0 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/AsyncUploadTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/AsyncRequestReadTest.java
@@ -39,7 +39,7 @@ import org.junit.Test;
/**
* @version $Revision: 889 $ $Date: 2009-09-14 14:52:16 +1000 (Mon, 14 Sep 2009) $
*/
-public class AsyncUploadTest
+public class AsyncRequestReadTest
{
private static Server server;
private static Connector connector;
@@ -71,7 +71,6 @@ public class AsyncUploadTest
byte[] content = new byte[16*4096];
Arrays.fill(content, (byte)120);
- long start = System.nanoTime();
OutputStream out = socket.getOutputStream();
out.write("POST / HTTP/1.1\r\n".getBytes());
out.write("Host: localhost\r\n".getBytes());
@@ -93,7 +92,6 @@ public class AsyncUploadTest
String response = IO.toString(in);
assertTrue(response.indexOf("200 OK")>0);
- long end = System.nanoTime();
assertEquals(content.length, total);
}
@@ -112,7 +110,6 @@ public class AsyncUploadTest
{
try
{
- Thread.sleep(100);
InputStream in = request.getInputStream();
byte[] b = new byte[4*4096];
int read;
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java
index b9aa342197..cdaac74141 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpConnectionTest.java
@@ -154,7 +154,7 @@ public class HttpConnectionTest
{
try
{
- ((StdErrLog)Log.getLogger(HttpConnection.class)).setHideStacks(true);
+ ((StdErrLog)Log.getLogger(AbstractHttpConnection.class)).setHideStacks(true);
String response;
@@ -185,7 +185,7 @@ public class HttpConnectionTest
}
finally
{
- ((StdErrLog)Log.getLogger(HttpConnection.class)).setHideStacks(false);
+ ((StdErrLog)Log.getLogger(AbstractHttpConnection.class)).setHideStacks(false);
}
}
@@ -335,7 +335,7 @@ public class HttpConnectionTest
Logger logger=null;
try
{
- ((StdErrLog)Log.getLogger(HttpConnection.class)).setHideStacks(true);
+ ((StdErrLog)Log.getLogger(AbstractHttpConnection.class)).setHideStacks(true);
response=connector.getResponses(requests);
offset = checkContains(response,offset,"HTTP/1.1 500");
offset = checkContains(response,offset,"Connection: close");
@@ -343,7 +343,7 @@ public class HttpConnectionTest
}
finally
{
- ((StdErrLog)Log.getLogger(HttpConnection.class)).setHideStacks(false);
+ ((StdErrLog)Log.getLogger(AbstractHttpConnection.class)).setHideStacks(false);
}
}
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java
index 40abd52291..5f5413ddc0 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpServerTestBase.java
@@ -931,7 +931,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
Socket client=newSocket(HOST,_connector.getLocalPort());
try
{
- ((StdErrLog)Log.getLogger(HttpConnection.class)).setHideStacks(true);
+ ((StdErrLog)Log.getLogger(AbstractHttpConnection.class)).setHideStacks(true);
OutputStream os=client.getOutputStream();
InputStream is=client.getInputStream();
@@ -959,7 +959,7 @@ public abstract class HttpServerTestBase extends HttpServerTestFixture
}
finally
{
- ((StdErrLog)Log.getLogger(HttpConnection.class)).setHideStacks(false);
+ ((StdErrLog)Log.getLogger(AbstractHttpConnection.class)).setHideStacks(false);
if (!client.isClosed())
client.close();
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpWriterTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpWriterTest.java
index 73828e81bf..314afb2df9 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/HttpWriterTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/HttpWriterTest.java
@@ -76,7 +76,7 @@ public class HttpWriterTest
};
- HttpConnection connection = new HttpConnection(null,endp,new Server(),null,generator,null)
+ AbstractHttpConnection connection = new AbstractHttpConnection(null,endp,new Server(),null,generator,null)
{
@Override
public Connection handle() throws IOException
@@ -169,7 +169,7 @@ public class HttpWriterTest
hb.setResponse(200,"OK");
- HttpConnection connection = new HttpConnection(null,endp,new Server(),null,hb,null)
+ AbstractHttpConnection connection = new AbstractHttpConnection(null,endp,new Server(),null,hb,null)
{
@Override
public Connection handle() throws IOException
diff --git a/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java b/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java
index 34e93f7ee6..12dbc80a78 100644
--- a/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java
+++ b/jetty-server/src/test/java/org/eclipse/jetty/server/ResponseTest.java
@@ -80,7 +80,7 @@ public class ResponseTest
@Test
public void testContentType() throws Exception
{
- HttpConnection connection = new TestHttpConnection(connector,new ByteArrayEndPoint(), connector.getServer());
+ AbstractHttpConnection connection = new TestHttpConnection(connector,new ByteArrayEndPoint(), connector.getServer());
Response response = connection.getResponse();
assertEquals(null,response.getContentType());
@@ -134,7 +134,7 @@ public class ResponseTest
public void testLocale() throws Exception
{
- HttpConnection connection = new TestHttpConnection(connector,new ByteArrayEndPoint(), connector.getServer());
+ AbstractHttpConnection connection = new TestHttpConnection(connector,new ByteArrayEndPoint(), connector.getServer());
Request request = connection.getRequest();
Response response = connection.getResponse();
ContextHandler context = new ContextHandler();
@@ -158,7 +158,7 @@ public class ResponseTest
@Test
public void testContentTypeCharacterEncoding() throws Exception
{
- HttpConnection connection = new TestHttpConnection(connector,new ByteArrayEndPoint(), connector.getServer());
+ AbstractHttpConnection connection = new TestHttpConnection(connector,new ByteArrayEndPoint(), connector.getServer());
Request request = connection.getRequest();
Response response = connection.getResponse();
@@ -332,7 +332,7 @@ public class ResponseTest
public void testEncodeRedirect()
throws Exception
{
- HttpConnection connection=new TestHttpConnection(connector,new ByteArrayEndPoint(), connector.getServer());
+ AbstractHttpConnection connection=new TestHttpConnection(connector,new ByteArrayEndPoint(), connector.getServer());
Response response = new Response(connection);
Request request = connection.getRequest();
request.setServerName("myhost");
@@ -397,7 +397,7 @@ public class ResponseTest
for (int i=1;i<tests.length;i++)
{
ByteArrayEndPoint out=new ByteArrayEndPoint(new byte[]{},4096);
- HttpConnection connection=new TestHttpConnection(connector,out, connector.getServer());
+ AbstractHttpConnection connection=new TestHttpConnection(connector,out, connector.getServer());
Response response = new Response(connection);
Request request = connection.getRequest();
request.setServerName("myhost");
@@ -491,9 +491,9 @@ public class ResponseTest
ByteArrayEndPoint endPoint = new ByteArrayEndPoint();
endPoint.setOut(new ByteArrayBuffer(1024));
endPoint.setGrowOutput(true);
- HttpConnection connection=new TestHttpConnection(connector, endPoint, connector.getServer());
+ AbstractHttpConnection connection=new TestHttpConnection(connector, endPoint, connector.getServer());
connection.getGenerator().reset();
- HttpConnection.setCurrentConnection(connection);
+ AbstractHttpConnection.setCurrentConnection(connection);
Response response = connection.getResponse();
connection.getRequest().setRequestURI("/test");
return response;
@@ -593,7 +593,7 @@ public class ResponseTest
}
}
- static class TestHttpConnection extends HttpConnection
+ static class TestHttpConnection extends AbstractHttpConnection
{
public TestHttpConnection(Connector connector, EndPoint endpoint, Server server)
diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java
index 3619e585cb..cc6373ad46 100644
--- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java
+++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/DefaultServlet.java
@@ -42,7 +42,7 @@ import org.eclipse.jetty.io.ByteArrayBuffer;
import org.eclipse.jetty.io.WriterOutputStream;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Dispatcher;
-import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.AbstractHttpConnection;
import org.eclipse.jetty.server.HttpOutput;
import org.eclipse.jetty.server.InclusiveByteRange;
import org.eclipse.jetty.server.ResourceCache;
@@ -771,7 +771,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
}
else
{
- Connector connector = HttpConnection.getCurrentConnection().getConnector();
+ Connector connector = AbstractHttpConnection.getCurrentConnection().getConnector();
direct=connector instanceof NIOConnector && ((NIOConnector)connector).getUseDirectBuffers() && !(connector instanceof SslConnector);
content_length=content.getContentLength();
}
@@ -787,7 +787,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
// has a filter already written to the response?
written = out instanceof HttpOutput
? ((HttpOutput)out).isWritten()
- : HttpConnection.getCurrentConnection().getGenerator().isWritten();
+ : AbstractHttpConnection.getCurrentConnection().getGenerator().isWritten();
}
catch(IllegalStateException e)
{
@@ -810,7 +810,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
if (response instanceof Response)
{
writeOptionHeaders(((Response)response).getHttpFields());
- ((HttpConnection.Output)out).sendContent(content);
+ ((AbstractHttpConnection.Output)out).sendContent(content);
}
else
{
@@ -818,7 +818,7 @@ public class DefaultServlet extends HttpServlet implements ResourceFactory
if (buffer!=null)
{
writeHeaders(response,content,content_length);
- ((HttpConnection.Output)out).sendContent(buffer);
+ ((AbstractHttpConnection.Output)out).sendContent(buffer);
}
else
{
diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ErrorPageErrorHandler.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ErrorPageErrorHandler.java
index ba2248d2e4..6fb32bc69c 100644
--- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ErrorPageErrorHandler.java
+++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ErrorPageErrorHandler.java
@@ -26,7 +26,7 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.http.HttpMethods;
import org.eclipse.jetty.server.Dispatcher;
-import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.AbstractHttpConnection;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ErrorHandler;
@@ -64,7 +64,7 @@ public class ErrorPageErrorHandler extends ErrorHandler
String method = request.getMethod();
if(!method.equals(HttpMethods.GET) && !method.equals(HttpMethods.POST) && !method.equals(HttpMethods.HEAD))
{
- HttpConnection.getCurrentConnection().getRequest().setHandled(true);
+ AbstractHttpConnection.getCurrentConnection().getRequest().setHandled(true);
return;
}
if (_errorPages!=null)
diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/Invoker.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/Invoker.java
index 9a37826418..a5e9ca6bdb 100644
--- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/Invoker.java
+++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/Invoker.java
@@ -28,7 +28,7 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.server.Dispatcher;
import org.eclipse.jetty.server.Handler;
-import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.AbstractHttpConnection;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.HandlerWrapper;
@@ -219,7 +219,7 @@ public class Invoker extends HttpServlet
if (holder!=null)
{
- final Request baseRequest=(request instanceof Request)?((Request)request):HttpConnection.getCurrentConnection().getRequest();
+ final Request baseRequest=(request instanceof Request)?((Request)request):AbstractHttpConnection.getCurrentConnection().getRequest();
holder.handle(baseRequest,
new InvokedRequest(request,included,servlet,servlet_path,path_info),
response);
diff --git a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java
index 04facf891f..5b8e117b81 100644
--- a/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java
+++ b/jetty-servlet/src/main/java/org/eclipse/jetty/servlet/ServletHandler.java
@@ -46,7 +46,7 @@ import org.eclipse.jetty.security.IdentityService;
import org.eclipse.jetty.security.SecurityHandler;
import org.eclipse.jetty.server.Dispatcher;
import org.eclipse.jetty.server.DispatcherType;
-import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.AbstractHttpConnection;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServletRequestHttpWrapper;
@@ -1328,7 +1328,7 @@ public class ServletHandler extends ScopedHandler
filter.doFilter(request, response, _next);
else
{
- final Request baseRequest=(request instanceof Request)?((Request)request):HttpConnection.getCurrentConnection().getRequest();
+ final Request baseRequest=(request instanceof Request)?((Request)request):AbstractHttpConnection.getCurrentConnection().getRequest();
final boolean suspendable=baseRequest.isAsyncSupported();
if (suspendable)
{
@@ -1353,7 +1353,7 @@ public class ServletHandler extends ScopedHandler
{
if (LOG.isDebugEnabled())
LOG.debug("call servlet " + _servletHolder);
- final Request baseRequest=(request instanceof Request)?((Request)request):HttpConnection.getCurrentConnection().getRequest();
+ final Request baseRequest=(request instanceof Request)?((Request)request):AbstractHttpConnection.getCurrentConnection().getRequest();
_servletHolder.handle(baseRequest,request, response);
}
else // Not found
diff --git a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CloseableDoSFilter.java b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CloseableDoSFilter.java
index 0bec5df794..9b2b659dcf 100644
--- a/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CloseableDoSFilter.java
+++ b/jetty-servlets/src/main/java/org/eclipse/jetty/servlets/CloseableDoSFilter.java
@@ -18,7 +18,7 @@ import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.AbstractHttpConnection;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@@ -37,7 +37,7 @@ public class CloseableDoSFilter extends DoSFilter
{
try
{
- Request base_request=(request instanceof Request)?(Request)request:HttpConnection.getCurrentConnection().getRequest();
+ Request base_request=(request instanceof Request)?(Request)request:AbstractHttpConnection.getCurrentConnection().getRequest();
base_request.getConnection().getEndPoint().close();
}
catch(IOException e)
diff --git a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java
index fd14c96be3..e339d082b8 100644
--- a/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java
+++ b/jetty-websocket/src/main/java/org/eclipse/jetty/websocket/WebSocketFactory.java
@@ -27,7 +27,7 @@ import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.http.HttpException;
import org.eclipse.jetty.http.HttpParser;
import org.eclipse.jetty.io.ConnectedEndPoint;
-import org.eclipse.jetty.server.HttpConnection;
+import org.eclipse.jetty.server.AbstractHttpConnection;
import org.eclipse.jetty.util.QuotedStringTokenizer;
import org.eclipse.jetty.util.log.Log;
import org.eclipse.jetty.util.log.Logger;
@@ -194,7 +194,7 @@ public class WebSocketFactory
int draft = request.getIntHeader("Sec-WebSocket-Version");
if (draft < 0)
draft = request.getIntHeader("Sec-WebSocket-Draft");
- HttpConnection http = HttpConnection.getCurrentConnection();
+ AbstractHttpConnection http = AbstractHttpConnection.getCurrentConnection();
ConnectedEndPoint endp = (ConnectedEndPoint)http.getEndPoint();
List<String> extensions_requested = new ArrayList<String>();

Back to the top