jetty-9 do not 200 until handled

This commit is contained in:
Greg Wilkins 2012-07-03 19:22:51 +02:00
parent 7d4da60d05
commit f8187106fc
7 changed files with 23 additions and 13 deletions

View File

@ -329,14 +329,14 @@ public class HttpGenerator
{
_noContent=true;
if (status!=101 )
if (status!=HttpStatus.SWITCHING_PROTOCOLS_101 )
{
header.put(HttpTokens.CRLF);
_state=State.COMPLETING_1XX;
return Result.FLUSH;
}
}
else if (status==204 || status==304)
else if (status==HttpStatus.NO_CONTENT_204 || status==HttpStatus.NOT_MODIFIED_304)
{
_noContent=true;
}

View File

@ -607,6 +607,7 @@ package org.eclipse.jetty.http;
*/
public class HttpStatus
{
public final static int NOT_SET_000 = 0;
public final static int CONTINUE_100 = 100;
public final static int SWITCHING_PROTOCOLS_101 = 101;
public final static int PROCESSING_102 = 102;

View File

@ -303,7 +303,7 @@ public abstract class HttpChannel
}
/* ------------------------------------------------------------ */
protected void process()
protected void handle()
{
LOG.debug("{} process",this);
@ -414,7 +414,7 @@ public abstract class HttpChannel
}
finally
{
_state.doComplete();
_state.completed();
_request.setHandled(true);
completed();
}

View File

@ -49,10 +49,10 @@ public class HttpChannelState implements AsyncContext, Continuation
private final static ContinuationThrowable __exception = new ContinuationThrowable();
// STATES:
// handling() suspend() unhandle() resume() complete() doComplete()
// handling() suspend() unhandle() resume() complete() completed()
// startAsync() dispatch()
// IDLE DISPATCHED COMPLETECALLED
// DISPATCHED ASYNCSTARTED UNCOMPLETED
// DISPATCHED ASYNCSTARTED COMPLETING
// ASYNCSTARTED ASYNCWAIT REDISPATCHING COMPLETECALLED
// REDISPATCHING REDISPATCHED
// ASYNCWAIT REDISPATCH COMPLETECALLED
@ -613,7 +613,7 @@ public class HttpChannelState implements AsyncContext, Continuation
/* (non-Javadoc)
* @see javax.servlet.ServletRequest#complete()
*/
protected void doComplete()
protected void completed()
{
final List<ContinuationListener> cListeners;
final List<AsyncListener> aListeners;
@ -1053,7 +1053,7 @@ public class HttpChannelState implements AsyncContext, Continuation
@Override
public void run()
{
_channel.process();
_channel.handle();
}
};
}

View File

@ -267,7 +267,7 @@ public class HttpConnection extends AbstractAsyncConnection
// will be left in !idle state so our outer loop will exit.
if (!_parser.isPersistent())
_generator.setPersistent(false);
_channel.process();
_channel.handle();
// Return if the channel is still processing the request
if (_channel.isSuspended())
@ -418,6 +418,8 @@ public class HttpConnection extends AbstractAsyncConnection
LOG.debug("{} completed");
// TODO handle connection upgrade!
// Reset everything for the next cycle.
HttpConnection.this.reset();

View File

@ -73,7 +73,7 @@ public class Response implements HttpServletResponse
private final HttpChannel _channel;
private final HttpFields _fields;
private final AtomicBoolean _committed = new AtomicBoolean(false);
private int _status=SC_OK;
private int _status=HttpStatus.NOT_SET_000;
private String _reason;
private Locale _locale;
private MimeTypes.Type _mimeType;
@ -83,8 +83,6 @@ public class Response implements HttpServletResponse
private PrintWriter _writer;
private long _contentLength=-1;
/* ------------------------------------------------------------ */
/**
*
@ -107,7 +105,7 @@ public class Response implements HttpServletResponse
*/
protected void recycle()
{
_status=SC_OK;
_status=HttpStatus.NOT_SET_000;
_reason=null;
_locale=null;
_mimeType=null;
@ -1051,6 +1049,9 @@ public class Response implements HttpServletResponse
if (!_committed.compareAndSet(false,true))
throw new IllegalStateException();
if (_status==HttpStatus.NOT_SET_000)
_status=HttpStatus.OK_200;
return new ResponseInfo(_channel.getRequest().getHttpVersion(),_fields,getLongContentLength(),getStatus(),getReason(),_channel.getRequest().isHead());
}

View File

@ -149,6 +149,12 @@ public class StatisticsHandler extends HandlerWrapper
Response response = request.getResponse();
switch (response.getStatus() / 100)
{
case 0:
if (request.isHandled())
_responses2xx.incrementAndGet();
else
_responses4xx.incrementAndGet();
break;
case 1:
_responses1xx.incrementAndGet();
break;