282807 Better handling of 100 continues if response committed
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@535 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
42a33c32fc
commit
1a47662030
|
@ -6,6 +6,7 @@ jetty-7.0.0.RC0 8 June 2009
|
|||
+ 280843 Buffer pool uses isHeader
|
||||
+ 271535 Adding integration tests, and enabling RFC2616 tests
|
||||
+ 281287 Handle date headers before 1 Jan 1970
|
||||
+ 282807 Better handling of 100 continues if response committed.
|
||||
|
||||
jetty-7.0.0.M4 1 June 2009
|
||||
+ 281059 NPE in QTP with debug on
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
package org.eclipse.jetty.http;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
|
||||
import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.io.BufferUtil;
|
||||
|
@ -306,6 +307,45 @@ public class HttpGenerator extends AbstractGenerator
|
|||
return super.isBufferFull() || _bufferChunked || _bypass || (_contentLength == HttpTokens.CHUNKED_CONTENT && _buffer != null && _buffer.space() < CHUNK_SPACE);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void send1xx(int code) throws IOException
|
||||
{
|
||||
if (_state != STATE_HEADER)
|
||||
return;
|
||||
|
||||
if (code<100||code>199)
|
||||
throw new IllegalArgumentException("!1xx");
|
||||
Status status=__status[code];
|
||||
if (status==null)
|
||||
throw new IllegalArgumentException(code+"?");
|
||||
|
||||
// get a header buffer
|
||||
if (_header == null)
|
||||
_header = _buffers.getHeader();
|
||||
|
||||
_header.put(status._responseLine);
|
||||
_header.put(HttpTokens.CRLF);
|
||||
|
||||
try
|
||||
{
|
||||
// nasty semi busy flush!
|
||||
while(_header.length()>0)
|
||||
{
|
||||
int len = _endp.flush(_header);
|
||||
if (len<0)
|
||||
throw new EofException();
|
||||
if (len==0)
|
||||
Thread.sleep(100);
|
||||
}
|
||||
}
|
||||
catch(InterruptedException e)
|
||||
{
|
||||
Log.debug(e);
|
||||
throw new InterruptedIOException(e.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
public void completeHeader(HttpFields fields, boolean allContentAdded) throws IOException
|
||||
{
|
||||
|
@ -682,7 +722,7 @@ public class HttpGenerator extends AbstractGenerator
|
|||
}
|
||||
}
|
||||
|
||||
if (!has_server && _status>100 && getSendServerVersion())
|
||||
if (!has_server && _status>199 && getSendServerVersion())
|
||||
_header.put(SERVER);
|
||||
|
||||
// end the header.
|
||||
|
@ -692,6 +732,8 @@ public class HttpGenerator extends AbstractGenerator
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* Complete the message.
|
||||
|
|
|
@ -307,12 +307,13 @@ public class HttpConnection implements Connection
|
|||
// If the client is expecting 100 CONTINUE, then send it now.
|
||||
if (_expect100Continue)
|
||||
{
|
||||
// is content missing?
|
||||
if (((HttpParser)_parser).getHeaderBuffer()==null || ((HttpParser)_parser).getHeaderBuffer().length()<2)
|
||||
{
|
||||
_generator.setResponse(HttpStatus.CONTINUE_100, null);
|
||||
_generator.completeHeader(null, true);
|
||||
_generator.complete();
|
||||
_generator.reset(false);
|
||||
if (_generator.isCommitted())
|
||||
throw new IllegalStateException("Committed before 100 Continues");
|
||||
|
||||
((HttpGenerator)_generator).send1xx(HttpStatus.CONTINUE_100);
|
||||
}
|
||||
_expect100Continue=false;
|
||||
}
|
||||
|
@ -800,11 +801,11 @@ public class HttpConnection implements Connection
|
|||
switch(HttpHeaderValues.CACHE.getOrdinal(value))
|
||||
{
|
||||
case HttpHeaderValues.CONTINUE_ORDINAL:
|
||||
_expect100Continue=true;
|
||||
_expect100Continue=_generator instanceof HttpGenerator;
|
||||
break;
|
||||
|
||||
case HttpHeaderValues.PROCESSING_ORDINAL:
|
||||
_expect102Processing=true;
|
||||
_expect102Processing=_generator instanceof HttpGenerator;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -819,10 +820,10 @@ public class HttpConnection implements Connection
|
|||
switch(cb.getOrdinal())
|
||||
{
|
||||
case HttpHeaderValues.CONTINUE_ORDINAL:
|
||||
_expect100Continue=true;
|
||||
_expect100Continue=_generator instanceof HttpGenerator;
|
||||
break;
|
||||
case HttpHeaderValues.PROCESSING_ORDINAL:
|
||||
_expect102Processing=true;
|
||||
_expect102Processing=_generator instanceof HttpGenerator;
|
||||
break;
|
||||
default:
|
||||
_expect=true;
|
||||
|
|
|
@ -379,22 +379,8 @@ public class Response implements HttpServletResponse
|
|||
*/
|
||||
public void sendProcessing() throws IOException
|
||||
{
|
||||
if (_connection.isExpecting102Processing())
|
||||
{
|
||||
Generator g = _connection.getGenerator();
|
||||
if (g instanceof HttpGenerator)
|
||||
{
|
||||
HttpGenerator generator = (HttpGenerator)g;
|
||||
boolean was_persistent=generator.isPersistent();
|
||||
generator.setResponse(102,null);
|
||||
generator.completeHeader(null,true);
|
||||
generator.setPersistent(true);
|
||||
generator.complete();
|
||||
generator.flushBuffer();
|
||||
generator.reset(false);
|
||||
generator.setPersistent(was_persistent);
|
||||
}
|
||||
}
|
||||
if (_connection.isExpecting102Processing() && !isCommitted())
|
||||
((HttpGenerator)_connection.getGenerator()).send1xx(HttpStatus.PROCESSING_102);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
|
Loading…
Reference in New Issue