diff --git a/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Generator.java b/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Generator.java index 160e8b2b87c..d43fecb6ab1 100644 --- a/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Generator.java +++ b/jetty-ajp/src/main/java/org/eclipse/jetty/ajp/Ajp13Generator.java @@ -245,7 +245,6 @@ public class Ajp13Generator extends AbstractGenerator // Handle the _content if (_head) { - content.clear(); _content = null; } @@ -271,54 +270,6 @@ public class Ajp13Generator extends AbstractGenerator } } - /* ------------------------------------------------------------ */ - /** - * Add content. - * - * @param b - * byte - * @return true if the buffers are full - * @throws IOException - */ - public boolean addContent(byte b) throws IOException - { - - if (_noContent) - return false; - - if (_last || _state == STATE_END) - throw new IllegalStateException("Closed"); - - if (!_endp.isOpen()) - { - _state = STATE_END; - return false; - } - - // Handle any unfinished business? - if (_content != null && _content.length() > 0) - { - flushBuffer(); - if (_content != null && _content.length() > 0) - throw new IllegalStateException("FULL"); - } - - _contentWritten++; - - // Handle the _content - if (_head) - return false; - - // we better check we have a buffer - initContent(); - - // Copy _content to buffer; - - _buffer.put(b); - - return _buffer.space() <= 1; - } - /* ------------------------------------------------------------ */ /** * Prepare buffer for unchecked writes. Prepare the generator buffer to receive unchecked writes diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/Generator.java b/jetty-http/src/main/java/org/eclipse/jetty/http/Generator.java index 78444e748b5..1800cf9bf50 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/Generator.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/Generator.java @@ -41,16 +41,6 @@ public interface Generator */ void addContent(Buffer content, boolean last) throws IOException; - /* ------------------------------------------------------------ */ - /** - * Add content. - * - * @param b byte - * @return true if the buffers are full - * @throws IOException - */ - boolean addContent(byte b) throws IOException; - void complete() throws IOException; void completeHeader(HttpFields responseFields, boolean last) throws IOException; 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 6d2c7dcc215..983a748b626 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 @@ -260,49 +260,6 @@ public class HttpGenerator extends AbstractGenerator } - /* ------------------------------------------------------------ */ - /** - * Add content. - * - * @param b byte - * @return true if the buffers are full - * @throws IOException - */ - public boolean addContent(byte b) throws IOException - { - if (_noContent) - throw new IllegalStateException("NO CONTENT"); - - if (_last || _state==STATE_END) - { - LOG.warn("Ignoring extra content {}",Byte.valueOf(b)); - return false; - } - - // Handle any unfinished business? - if (_content != null && _content.length()>0 || _bufferChunked) - { - flushBuffer(); - if (_content != null && _content.length()>0 || _bufferChunked) - throw new IllegalStateException("FULL"); - } - - _contentWritten++; - - // Handle the _content - if (_head) - return false; - - // we better check we have a buffer - if (_buffer == null) - _buffer = _buffers.getBuffer(); - - // Copy _content to buffer; - _buffer.put(b); - - return _buffer.space()<=(_contentLength == HttpTokens.CHUNKED_CONTENT?CHUNK_SPACE:0); - } - /* ------------------------------------------------------------ */ /** Prepare buffer for unchecked writes. * Prepare the generator buffer to receive unchecked writes diff --git a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java index b317a5e7c6c..a9ef1f67146 100644 --- a/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java +++ b/jetty-server/src/main/java/org/eclipse/jetty/server/HttpOutput.java @@ -44,6 +44,7 @@ public class HttpOutput extends ServletOutputStream protected final AbstractHttpConnection _connection; protected final AbstractGenerator _generator; private boolean _closed; + private ByteArrayBuffer _onebyte; // These are held here for reuse by Writer String _characterEncoding; @@ -116,6 +117,7 @@ public class HttpOutput extends ServletOutputStream write(new ByteArrayBuffer(b)); } + /* ------------------------------------------------------------ */ /* * @see java.io.OutputStream#write(int) @@ -123,31 +125,12 @@ public class HttpOutput extends ServletOutputStream @Override public void write(int b) throws IOException { - if (_closed) - throw new IOException("Closed"); - if (!_generator.isOpen()) - throw new EofException(); - - // Block until we can add _content. - while (_generator.isBufferFull()) - { - _generator.blockForOutput(getMaxIdleTime()); - if (_closed) - throw new IOException("Closed"); - if (!_generator.isOpen()) - throw new EofException(); - } - - // Add the _content - if (_generator.addContent((byte)b)) - // Buffers are full so commit. - _connection.commitResponse(Generator.MORE); - - if (_generator.isAllContentWritten()) - { - flush(); - close(); - } + if (_onebyte==null) + _onebyte=new ByteArrayBuffer(1); + else + _onebyte.clear(); + _onebyte.put((byte)b); + write(_onebyte); } /* ------------------------------------------------------------ */ diff --git a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYAsyncConnection.java b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYAsyncConnection.java index 824cd0acce3..01a82ca5593 100644 --- a/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYAsyncConnection.java +++ b/jetty-spdy/spdy-jetty-http/src/main/java/org/eclipse/jetty/spdy/http/ServerHTTPSPDYAsyncConnection.java @@ -698,15 +698,6 @@ public class ServerHTTPSPDYAsyncConnection extends AbstractHttpConnection implem return null; } - @Override - public boolean addContent(byte b) throws IOException - { - // In HttpGenerator, writing one byte only has a different path than - // writing a buffer. Here we normalize these path to keep it simpler. - addContent(new ByteArrayBuffer(new byte[]{b}), false); - return false; - } - @Override public void addContent(Buffer content, boolean last) throws IOException {