304781 Reset HttpExchange timeout on slow request content. 304801 SSL connections FULL fix
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1342 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
435a0d256b
commit
66533d0af9
|
@ -25,6 +25,8 @@ jetty-7.0.2-SNAPSHOT
|
|||
+ 304532 Skip some tests on IBM JVMs until resolved
|
||||
+ 304658 Inconsistent Expires date format in Set-Cookie headers with maxAge=0
|
||||
+ 304698 org.eclipse.jetty.http.HttpFields$DateGenerator.formatCookieDate() uses wrong (?) date format
|
||||
+ 304781 Reset HttpExchange timeout on slow request content.
|
||||
+ 304801 SSL connections FULL fix
|
||||
+ JETTY-776 Make new session-tests module to concentrate all reusable session clustering test code
|
||||
+ JETTY-910 Allow request listeners to access session
|
||||
+ JETTY-983 Range handling cleanup
|
||||
|
|
|
@ -141,7 +141,6 @@ public class HttpConnection implements Connection
|
|||
try
|
||||
{
|
||||
int no_progress = 0;
|
||||
long flushed = 0;
|
||||
|
||||
boolean failed = false;
|
||||
while (_endp.isBufferingInput() || _endp.isOpen())
|
||||
|
@ -204,10 +203,11 @@ public class HttpConnection implements Connection
|
|||
{
|
||||
if (_exchange == null)
|
||||
continue;
|
||||
flushed = _generator.flushBuffer();
|
||||
io += flushed;
|
||||
}
|
||||
|
||||
long flushed = _generator.flushBuffer();
|
||||
io += flushed;
|
||||
|
||||
if (!_generator.isComplete())
|
||||
{
|
||||
InputStream in = _exchange.getRequestContentSource();
|
||||
|
@ -216,11 +216,15 @@ public class HttpConnection implements Connection
|
|||
if (_requestContentChunk == null || _requestContentChunk.length() == 0)
|
||||
{
|
||||
_requestContentChunk = _exchange.getRequestContentChunk();
|
||||
_destination.getHttpClient().schedule(_timeout);
|
||||
|
||||
if (_requestContentChunk != null)
|
||||
_generator.addContent(_requestContentChunk,false);
|
||||
else
|
||||
_generator.complete();
|
||||
io += _generator.flushBuffer();
|
||||
|
||||
flushed = _generator.flushBuffer();
|
||||
io += flushed;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -235,7 +239,7 @@ public class HttpConnection implements Connection
|
|||
}
|
||||
|
||||
// If we are not ended then parse available
|
||||
if (!_parser.isComplete() && _generator.isCommitted())
|
||||
if (!_parser.isComplete() && (_generator.isComplete() || _generator.isCommitted() && !_endp.isBlocking()))
|
||||
{
|
||||
long filled = _parser.parseAvailable();
|
||||
io += filled;
|
||||
|
@ -248,7 +252,8 @@ public class HttpConnection implements Connection
|
|||
// SSL may need an extra flush as it may have made "no progress" while actually doing a handshake.
|
||||
if (_endp instanceof SslSelectChannelEndPoint && !_generator.isComplete() && !_generator.isEmpty())
|
||||
{
|
||||
if (_generator.flushBuffer()>0)
|
||||
long flushed = _generator.flushBuffer();
|
||||
if (flushed>0)
|
||||
continue;
|
||||
}
|
||||
return this;
|
||||
|
@ -550,22 +555,9 @@ public class HttpConnection implements Connection
|
|||
}
|
||||
|
||||
public void close() throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
_endp.close();
|
||||
}
|
||||
finally
|
||||
{
|
||||
HttpExchange exchange=_exchange;
|
||||
if (exchange!=null)
|
||||
{
|
||||
int status = exchange.getStatus();
|
||||
if (status>HttpExchange.STATUS_START && status<HttpExchange.STATUS_COMPLETED)
|
||||
System.err.println("\nCLOSE "+exchange);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setIdleTimeout()
|
||||
{
|
||||
|
|
|
@ -92,7 +92,7 @@ public class ErrorStatusTest
|
|||
protected void doPutFail(int status)
|
||||
throws Exception
|
||||
{
|
||||
System.err.println(getName());
|
||||
// System.err.println(getName());
|
||||
|
||||
startClient(getRealm());
|
||||
|
||||
|
@ -115,7 +115,7 @@ public class ErrorStatusTest
|
|||
protected void doGetFail(int status)
|
||||
throws Exception
|
||||
{
|
||||
System.err.println(getName());
|
||||
// System.err.println(getName());
|
||||
|
||||
startClient(getRealm());
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ import junit.framework.TestCase;
|
|||
import org.eclipse.jetty.client.security.ProxyAuthorization;
|
||||
import org.eclipse.jetty.http.HttpHeaders;
|
||||
import org.eclipse.jetty.http.HttpMethods;
|
||||
import org.eclipse.jetty.http.HttpStatus;
|
||||
import org.eclipse.jetty.io.Buffer;
|
||||
import org.eclipse.jetty.io.ByteArrayBuffer;
|
||||
import org.eclipse.jetty.io.EofException;
|
||||
|
@ -56,6 +55,9 @@ public class HttpExchangeTest extends TestCase
|
|||
{
|
||||
startServer();
|
||||
_httpClient=new HttpClient();
|
||||
_httpClient.setIdleTimeout(2000);
|
||||
_httpClient.setTimeout(2500);
|
||||
_httpClient.setConnectTimeout(1000);
|
||||
_httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
|
||||
_httpClient.setMaxConnectionsPerAddress(_maxConnectionsPerAddress);
|
||||
_httpClient.start();
|
||||
|
@ -257,6 +259,67 @@ public class HttpExchangeTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
public void testSlowPost() throws Exception
|
||||
{
|
||||
ContentExchange httpExchange=new ContentExchange()
|
||||
{
|
||||
};
|
||||
//httpExchange.setURL(_scheme+"localhost:"+_port+"/");
|
||||
httpExchange.setURL(_scheme+"localhost:"+_port);
|
||||
httpExchange.setMethod(HttpMethods.POST);
|
||||
|
||||
final String data="012345678901234567890123456789012345678901234567890123456789";
|
||||
|
||||
InputStream content = new InputStream()
|
||||
{
|
||||
int _index=0;
|
||||
|
||||
@Override
|
||||
public int read() throws IOException
|
||||
{
|
||||
if (_index>=data.length())
|
||||
return -1;
|
||||
|
||||
return data.charAt(_index++);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] b, int off, int len) throws IOException
|
||||
{
|
||||
if (_index>=data.length())
|
||||
return -1;
|
||||
|
||||
//System.err.println("sleep "+_index);
|
||||
try
|
||||
{
|
||||
Thread.sleep(250);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
int l=0;
|
||||
|
||||
while (l<5 && _index<data.length() && l<len)
|
||||
b[off+l++]=(byte)data.charAt(_index++);
|
||||
return l;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
httpExchange.setRequestContentSource(content);
|
||||
//httpExchange.setRequestContent(new ByteArrayBuffer(data));
|
||||
|
||||
_httpClient.send(httpExchange);
|
||||
|
||||
int status = httpExchange.waitForDone();
|
||||
//httpExchange.waitForStatus(HttpExchange.STATUS_COMPLETED);
|
||||
String result=httpExchange.getResponseContent();
|
||||
assertEquals(HttpExchange.STATUS_COMPLETED, status);
|
||||
assertEquals(data,result);
|
||||
}
|
||||
|
||||
public void testProxy() throws Exception
|
||||
{
|
||||
if (_scheme.equals("https://"))
|
||||
|
@ -327,7 +390,7 @@ public class HttpExchangeTest extends TestCase
|
|||
}
|
||||
catch (EofException e)
|
||||
{
|
||||
System.err.println(e);
|
||||
System.err.println("HttpExchangeTest#copyStream: "+e);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
|
|
|
@ -34,7 +34,10 @@ public class SslHttpExchangeTest extends HttpExchangeTest
|
|||
_scheme="https://";
|
||||
startServer();
|
||||
_httpClient=new HttpClient();
|
||||
// _httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
|
||||
_httpClient.setIdleTimeout(2000);
|
||||
_httpClient.setTimeout(2500);
|
||||
_httpClient.setConnectTimeout(1000);
|
||||
_httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
|
||||
_httpClient.setConnectorType(HttpClient.CONNECTOR_SOCKET);
|
||||
_httpClient.setMaxConnectionsPerAddress(2);
|
||||
_httpClient.start();
|
||||
|
|
|
@ -167,8 +167,13 @@ public class HttpGenerator extends AbstractGenerator
|
|||
if (!_endp.isOpen())
|
||||
throw new EofException();
|
||||
flushBuffer();
|
||||
if (_content != null && _content.length()>0 || _bufferChunked)
|
||||
throw new IllegalStateException("FULL");
|
||||
if (_content != null && _content.length()>0)
|
||||
{
|
||||
Buffer nc=_buffers.getBuffer(_content.length()+content.length());
|
||||
nc.put(_content);
|
||||
nc.put(content);
|
||||
_content=nc;
|
||||
}
|
||||
}
|
||||
|
||||
_content = content;
|
||||
|
@ -186,7 +191,7 @@ public class HttpGenerator extends AbstractGenerator
|
|||
// Make _content a direct buffer
|
||||
_bypass = true;
|
||||
}
|
||||
else
|
||||
else if (!_bufferChunked)
|
||||
{
|
||||
// Yes - so we better check we have a buffer
|
||||
if (_buffer == null)
|
||||
|
|
Loading…
Reference in New Issue