/** * Must be called to ensure the internal cache is flushed and the closing chunk is written. * @throws IOException */ public void finish() throws IOException { if (!this.wroteLastChunk) { flushCache(); writeClosingChunk(); this.wroteLastChunk = true; } }
public int read() throws IOException { int noRead = 0; while (!hasBufferedData()) { noRead = fillBuffer(); if (noRead == -1) { return -1; } } return this.buffer[this.bufferpos++] & 0xff; }
protected SessionInputBuffer createSessionInputBuffer( final Socket socket, int buffersize, final HttpParams params) throws IOException { return new SocketInputBuffer(socket, buffersize, params); }
protected OutputStream doSerialize( final SessionOutputBuffer outbuffer, final HttpMessage message) throws HttpException, IOException { long len = this.lenStrategy.determineLength(message); if (len == ContentLengthStrategy.CHUNKED) { return new ChunkedOutputStream(outbuffer); } else if (len == ContentLengthStrategy.IDENTITY) { return new IdentityOutputStream(outbuffer); } else { return new ContentLengthOutputStream(outbuffer, len); } }
protected SessionOutputBuffer createSessionOutputBuffer( final Socket socket, int buffersize, final HttpParams params) throws IOException { return new SocketOutputBuffer(socket, buffersize, params); }
/** * Read some bytes from the stream. * @param b The byte array that will hold the contents from the stream. * @return The number of bytes returned or -1 if the end of stream has been * reached. * @see java.io.InputStream#read(byte[]) * @throws IOException if an IO problem occurs. */ public int read (byte[] b) throws IOException { return read(b, 0, b.length); }
protected HttpMessageWriter createResponseWriter( final SessionOutputBuffer buffer, final HttpParams params) { // override in derived class to specify a line formatter return new HttpResponseWriter(buffer, null, params); }
protected HttpMessageWriter createRequestWriter( final SessionOutputBuffer buffer, final HttpParams params) { // override in derived class to specify a line formatter return new HttpRequestWriter(buffer, null, params); }
public void write(byte[] b) throws IOException { write(b, 0, b.length); }
@Override protected OutputStream createOutputStream(final long len, final SessionOutputBuffer outbuffer) { if (len == ContentLengthStrategy.CHUNKED) { return new ChunkedOutputStream(chunkSize, outbuffer); } return super.createOutputStream(len, outbuffer); } }
public int read(final byte[] b) throws IOException { if (b == null) { return 0; } return read(b, 0, b.length); }
public void write(final byte[] b) throws IOException { if (b == null) { return; } write(b, 0, b.length); }
/** * Read more bytes from the stream. * @param b The byte array to put the new data in. * @return The number of bytes read into the buffer. * @throws IOException If an IO problem occurs * @see java.io.InputStream#read(byte[]) */ public int read(byte[] b) throws IOException { return read(b, 0, b.length); }
/** * Writes the array. If the array does not fit within the buffer, it is * not split, but rather written out as one large chunk. * @param b * @throws IOException */ public void write(byte b[]) throws IOException { write(b, 0, b.length); }
public void write(byte[] b) throws IOException { write(b, 0, b.length); }
protected HttpMessageParser createResponseParser( final SessionInputBuffer buffer, final HttpResponseFactory responseFactory, final HttpParams params) { // override in derived class to specify a line parser return new HttpResponseParser(buffer, null, responseFactory, params); }
protected HttpMessageParser createRequestParser( final SessionInputBuffer buffer, final HttpRequestFactory requestFactory, final HttpParams params) { // override in derived class to specify a line parser return new HttpRequestParser(buffer, null, requestFactory, params); }
protected SessionInputBuffer createHttpDataReceiver( final Socket socket, int buffersize, final HttpParams params) throws IOException { return new SocketInputBuffer(socket, buffersize, params); }
protected SessionOutputBuffer createHttpDataTransmitter( final Socket socket, int buffersize, final HttpParams params) throws IOException { return new SocketOutputBuffer(socket, buffersize, params); }
/** * Read some bytes from the stream. * @param b The byte array that will hold the contents from the stream. * @return The number of bytes returned or -1 if the end of stream has been * reached. * @throws IOException in case of an I/O error */ @Override public int read(final byte[] b) throws IOException { return read(b, 0, b.length); }