protected SessionInputBuffer createHttpDataReceiver( final Socket socket, int buffersize, final HttpParams params) throws IOException { return new SocketInputBuffer(socket, buffersize, params); }
public boolean isDataAvailable(int timeout) throws IOException { boolean result = hasBufferedData(); if (!result) { int oldtimeout = this.socket.getSoTimeout(); try { this.socket.setSoTimeout(timeout); fillBuffer(); result = hasBufferedData(); } catch (InterruptedIOException e) { if (!(e instanceof SocketTimeoutException)) { throw e; } } finally { socket.setSoTimeout(oldtimeout); } } return result; }
public SocketInputBuffer( final Socket socket, int buffersize, final HttpParams params) throws IOException { super(); if (socket == null) { throw new IllegalArgumentException("Socket may not be null"); } this.socket = socket; // BEGIN android-changed // Workaround for http://b/3514259. We take 'buffersize' as a hint in // the weakest sense, and always use an 8KiB heap buffer and leave the // kernel buffer size alone, trusting the system to have set a // network-appropriate default. init(socket.getInputStream(), 8192, params); // END android-changed }
public boolean isStale() { if (!isOpen()) { return true; } try { // BEGIN android-added // don't reuse connections when the socket input stream is exhausted if (inbuffer instanceof SocketInputBuffer) { return ((SocketInputBuffer) inbuffer).isStale(); } // END android-added this.inbuffer.isDataAvailable(1); return false; } catch (IOException ex) { return true; } }
public boolean isStale() { if (!isOpen()) { return true; } try { // BEGIN android-added // don't reuse connections when the socket input stream is exhausted if (inbuffer instanceof SocketInputBuffer) { return ((SocketInputBuffer) inbuffer).isStale(); } // END android-added this.inbuffer.isDataAvailable(1); return false; } catch (IOException ex) { return true; } }
/** * Returns true if the connection is probably functional. It's insufficient * to rely on isDataAvailable() returning normally; that approach cannot * distinguish between an exhausted stream and a stream with zero bytes * buffered. * * @hide */ public boolean isStale() throws IOException { if (hasBufferedData()) { return false; } int oldTimeout = this.socket.getSoTimeout(); try { this.socket.setSoTimeout(1); return fillBuffer() == -1; } catch (SocketTimeoutException e) { return false; // the connection is not stale; hooray } catch (IOException e) { return true; // the connection is stale, the read or soTimeout failed. } finally { this.socket.setSoTimeout(oldTimeout); } } // END android-added
protected SessionInputBuffer createSessionInputBuffer( final Socket socket, int buffersize, final HttpParams params) throws IOException { return new SocketInputBuffer(socket, buffersize, params); }
public SocketInputBuffer( final Socket socket, int buffersize, final HttpParams params) throws IOException { super(); if (socket == null) { throw new IllegalArgumentException("Socket may not be null"); } this.socket = socket; // BEGIN android-changed // Workaround for http://b/3514259. We take 'buffersize' as a hint in // the weakest sense, and always use an 8KiB heap buffer and leave the // kernel buffer size alone, trusting the system to have set a // network-appropriate default. init(socket.getInputStream(), 8192, params); // END android-changed }
public boolean isStale() { if (!isOpen()) { return true; } try { // BEGIN android-added // don't reuse connections when the socket input stream is exhausted if (inbuffer instanceof SocketInputBuffer) { return ((SocketInputBuffer) inbuffer).isStale(); } // END android-added this.inbuffer.isDataAvailable(1); return false; } catch (IOException ex) { return true; } }
public boolean isDataAvailable(final int timeout) throws IOException { boolean result = hasBufferedData(); if (!result) { final int oldtimeout = this.socket.getSoTimeout(); try { this.socket.setSoTimeout(timeout); fillBuffer(); result = hasBufferedData(); } finally { socket.setSoTimeout(oldtimeout); } } return result; }
protected SessionInputBuffer createSessionInputBuffer( final Socket socket, int buffersize, final HttpParams params) throws IOException { return new SocketInputBuffer(socket, buffersize, params); }
public SocketInputBuffer( final Socket socket, int buffersize, final HttpParams params) throws IOException { super(); if (socket == null) { throw new IllegalArgumentException("Socket may not be null"); } this.socket = socket; // BEGIN android-changed // Workaround for http://b/3514259. We take 'buffersize' as a hint in // the weakest sense, and always use an 8KiB heap buffer and leave the // kernel buffer size alone, trusting the system to have set a // network-appropriate default. init(socket.getInputStream(), 8192, params); // END android-changed }
public boolean isStale() { if (!isOpen()) { return true; } try { // BEGIN android-added // don't reuse connections when the socket input stream is exhausted if (inbuffer instanceof SocketInputBuffer) { return ((SocketInputBuffer) inbuffer).isStale(); } // END android-added this.inbuffer.isDataAvailable(1); return false; } catch (IOException ex) { return true; } }
public boolean isDataAvailable(final int timeout) throws IOException { boolean result = hasBufferedData(); if (!result) { final int oldtimeout = this.socket.getSoTimeout(); try { this.socket.setSoTimeout(timeout); fillBuffer(); result = hasBufferedData(); } finally { socket.setSoTimeout(oldtimeout); } } return result; }
protected SessionInputBuffer createSessionInputBuffer( final Socket socket, int buffersize, final HttpParams params) throws IOException { return new SocketInputBuffer(socket, buffersize, params); }
public SocketInputBuffer( final Socket socket, int buffersize, final HttpParams params) throws IOException { super(); if (socket == null) { throw new IllegalArgumentException("Socket may not be null"); } this.socket = socket; // BEGIN android-changed // Workaround for http://b/3514259. We take 'buffersize' as a hint in // the weakest sense, and always use an 8KiB heap buffer and leave the // kernel buffer size alone, trusting the system to have set a // network-appropriate default. init(socket.getInputStream(), 8192, params); // END android-changed }
public boolean isStale() { if (!isOpen()) { return true; } try { // BEGIN android-added // don't reuse connections when the socket input stream is exhausted if (inbuffer instanceof SocketInputBuffer) { return ((SocketInputBuffer) inbuffer).isStale(); } // END android-added this.inbuffer.isDataAvailable(1); return false; } catch (IOException ex) { return true; } }
public boolean isDataAvailable(final int timeout) throws IOException { boolean result = hasBufferedData(); if (!result) { final int oldtimeout = this.socket.getSoTimeout(); try { this.socket.setSoTimeout(timeout); fillBuffer(); result = hasBufferedData(); } finally { socket.setSoTimeout(oldtimeout); } } return result; }
protected SessionInputBuffer createHttpDataReceiver( final Socket socket, int buffersize, final HttpParams params) throws IOException { return new SocketInputBuffer(socket, buffersize, params); }
public SocketInputBuffer( final Socket socket, int buffersize, final HttpParams params) throws IOException { super(); if (socket == null) { throw new IllegalArgumentException("Socket may not be null"); } this.socket = socket; // BEGIN android-changed // Workaround for http://b/3514259. We take 'buffersize' as a hint in // the weakest sense, and always use an 8KiB heap buffer and leave the // kernel buffer size alone, trusting the system to have set a // network-appropriate default. init(socket.getInputStream(), 8192, params); // END android-changed }