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 0ff501e8644..3cb1a90656e 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 @@ -172,6 +172,9 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen { } + /** + * @throws IOException + */ protected void commitRequest() throws IOException { synchronized (this) @@ -223,6 +226,7 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen requestHeaders.putLongField(HttpHeaders.CONTENT_LENGTH, requestContent.length()); _generator.completeHeader(requestHeaders,false); _generator.addContent(new View(requestContent),true); + _exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_RESPONSE); } else { @@ -230,24 +234,14 @@ public abstract class AbstractHttpConnection extends AbstractConnection implemen if (requestContentStream != null) { _generator.completeHeader(requestHeaders, false); - int available = requestContentStream.available(); - if (available > 0) - { - // TODO deal with any known content length - // TODO reuse this buffer! - byte[] buf = new byte[available]; - int length = requestContentStream.read(buf); - _generator.addContent(new ByteArrayBuffer(buf, 0, length), false); - } } else { requestHeaders.remove(HttpHeaders.CONTENT_LENGTH); _generator.completeHeader(requestHeaders, true); + _exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_RESPONSE); } } - - _exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_RESPONSE); } } 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 1ea6b06721a..dbb75d897cd 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 @@ -114,6 +114,8 @@ public class AsyncHttpConnection extends AbstractHttpConnection implements Async Buffer chunk=_requestContentChunk; _requestContentChunk=exchange.getRequestContentChunk(null); _generator.addContent(chunk,_requestContentChunk==null); + if (_requestContentChunk==null) + exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_RESPONSE); } } } diff --git a/jetty-client/src/main/java/org/eclipse/jetty/client/BlockingHttpConnection.java b/jetty-client/src/main/java/org/eclipse/jetty/client/BlockingHttpConnection.java index c10319fdeb9..454cee300ee 100644 --- a/jetty-client/src/main/java/org/eclipse/jetty/client/BlockingHttpConnection.java +++ b/jetty-client/src/main/java/org/eclipse/jetty/client/BlockingHttpConnection.java @@ -122,6 +122,8 @@ public class BlockingHttpConnection extends AbstractHttpConnection Buffer chunk=_requestContentChunk; _requestContentChunk=exchange.getRequestContentChunk(null); _generator.addContent(chunk,_requestContentChunk==null); + if (_requestContentChunk==null) + exchange.setStatus(HttpExchange.STATUS_WAITING_FOR_RESPONSE); } } }