Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2010-03-05 12:04:05 +0000
committerGreg Wilkins2010-03-05 12:04:05 +0000
commit66533d0af9db359abf6b23c72938f4b943b3c60b (patch)
treeb3772ac88fffb48d339bbcc7d50f724c033950c1
parent435a0d256bd0d2252bf9dd34f68e4875d8f08664 (diff)
downloadorg.eclipse.jetty.project-66533d0af9db359abf6b23c72938f4b943b3c60b.tar.gz
org.eclipse.jetty.project-66533d0af9db359abf6b23c72938f4b943b3c60b.tar.xz
org.eclipse.jetty.project-66533d0af9db359abf6b23c72938f4b943b3c60b.zip
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
-rw-r--r--VERSION.txt2
-rw-r--r--jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java34
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/ErrorStatusTest.java4
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java67
-rw-r--r--jetty-client/src/test/java/org/eclipse/jetty/client/SslHttpExchangeTest.java5
-rw-r--r--jetty-http/src/main/java/org/eclipse/jetty/http/HttpGenerator.java11
6 files changed, 94 insertions, 29 deletions
diff --git a/VERSION.txt b/VERSION.txt
index 2511c23eda..0ea76fa3ea 100644
--- a/VERSION.txt
+++ b/VERSION.txt
@@ -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
diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java
index 42d00c31ba..a98ee83a9e 100644
--- a/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java
+++ b/jetty-client/src/main/java/org/eclipse/jetty/client/HttpConnection.java
@@ -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,9 +203,10 @@ public class HttpConnection implements Connection
{
if (_exchange == null)
continue;
- flushed = _generator.flushBuffer();
- io += flushed;
}
+
+ long flushed = _generator.flushBuffer();
+ io += flushed;
if (!_generator.isComplete())
{
@@ -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,12 +239,12 @@ 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;
}
-
+
if (io > 0)
no_progress = 0;
else if (no_progress++ >= 2 && !_endp.isBlocking())
@@ -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;
@@ -551,20 +556,7 @@ 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);
- }
- }
+ _endp.close();
}
public void setIdleTimeout()
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/ErrorStatusTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/ErrorStatusTest.java
index 42d7222325..f415734117 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/ErrorStatusTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/ErrorStatusTest.java
@@ -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());
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java
index 804c7d7ea3..a0dc69d08f 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/HttpExchangeTest.java
@@ -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();
@@ -256,7 +258,68 @@ public class HttpExchangeTest extends TestCase
Thread.sleep(5);
}
}
+
+ 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)
{
diff --git a/jetty-client/src/test/java/org/eclipse/jetty/client/SslHttpExchangeTest.java b/jetty-client/src/test/java/org/eclipse/jetty/client/SslHttpExchangeTest.java
index 4b965115dc..6b4faf7c3f 100644
--- a/jetty-client/src/test/java/org/eclipse/jetty/client/SslHttpExchangeTest.java
+++ b/jetty-client/src/test/java/org/eclipse/jetty/client/SslHttpExchangeTest.java
@@ -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();
diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpGenerator.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpGenerator.java
index 696cc6b65a..d21fdd4071 100644
--- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpGenerator.java
+++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpGenerator.java
@@ -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)

Back to the top