@Override public final void disconnect() { // Calling disconnect() before a connection exists should have no effect. if (httpEngine == null) return; httpEngine.cancel(); // This doesn't close the stream because doing so would require all stream // access to be synchronized. It's expected that the thread using the // connection will close its streams directly. If it doesn't, the worst // case is that the GzipSource's Inflater won't be released until it's // finalized. (This logs a warning on Android.) }
@Override public final void disconnect() { // Calling disconnect() before a connection exists should have no effect. if (httpEngine == null) return; httpEngine.disconnect(); // This doesn't close the stream because doing so would require all stream // access to be synchronized. It's expected that the thread using the // connection will close its streams directly. If it doesn't, the worst // case is that the GzipSource's Inflater won't be released until it's // finalized. (This logs a warning on Android.) }
private StreamWebSocket(StreamAllocation streamAllocation, Random random, ExecutorService replyExecutor, WebSocketListener listener, String url) { super(true /* is client */, streamAllocation.connection().source, streamAllocation.connection().sink, random, replyExecutor, listener, url); this.streamAllocation = streamAllocation; this.replyExecutor = replyExecutor; }
@Override public final Map<String, List<String>> getHeaderFields() { try { return OkHeaders.toMultimap(getHeaders(), StatusLine.get(getResponse().getResponse()).toString()); } catch (IOException e) { return Collections.emptyMap(); } }
/** * Returns the value of the field corresponding to the {@code fieldName}, or * null if there is no such field. If the field has multiple values, the * last value is returned. */ @Override public final String getHeaderField(String fieldName) { try { return fieldName == null ? StatusLine.get(getResponse().getResponse()).toString() : getHeaders().get(fieldName); } catch (IOException e) { return null; } }
@Override protected boolean hasResponseBody(Response response) { return HttpEngine.hasBody(response); }
@Override protected Handshake handshake() { if (delegate.httpEngine == null) { throw new IllegalStateException("Connection has not yet been established"); } // If there's a response, get the handshake from there so that caching // works. Otherwise get the handshake from the connection because we might // have not connected yet. return delegate.httpEngine.hasResponse() ? delegate.httpEngine.getResponse().handshake() : delegate.handshake; }
@Override protected void close() throws IOException { replyExecutor.shutdown(); streamAllocation.noNewStreams(); streamAllocation.streamFinished(streamAllocation.stream()); } }
@Override public final Map<String, List<String>> getRequestProperties() { if (connected) { throw new IllegalStateException( "Cannot access request header fields after connection is set"); } return OkHeaders.toMultimap(requestHeaders.build(), null); }
@Override public final int getResponseCode() throws IOException { return getResponse().getResponse().code(); }
@Override public final Map<String, List<String>> getHeaderFields() { try { return OkHeaders.toMultimap(getHeaders(), StatusLine.get(getResponse().getResponse()).toString()); } catch (IOException e) { return Collections.emptyMap(); } }
/** * Returns the value of the field corresponding to the {@code fieldName}, or * null if there is no such field. If the field has multiple values, the * last value is returned. */ @Override public final String getHeaderField(String fieldName) { try { return fieldName == null ? StatusLine.get(getResponse().getResponse()).toString() : getHeaders().get(fieldName); } catch (IOException e) { return null; } }
if (!logBody || !HttpEngine.hasBody(response)) { logger.log("<-- END HTTP"); } else if (bodyEncoded(response.headers())) {
@Override protected Handshake handshake() { if (delegate.httpEngine == null) { throw new IllegalStateException("Connection has not yet been established"); } // If there's a response, get the handshake from there so that caching // works. Otherwise get the handshake from the connection because we might // have not connected yet. return delegate.httpEngine.hasResponse() ? delegate.httpEngine.getResponse().handshake() : delegate.handshake; }
@Override public final Map<String, List<String>> getRequestProperties() { if (connected) { throw new IllegalStateException( "Cannot access request header fields after connection is set"); } return OkHeaders.toMultimap(requestHeaders.build(), null); }
@Override public final void disconnect() { // Calling disconnect() before a connection exists should have no effect. if (httpEngine == null) return; httpEngine.disconnect(); // This doesn't close the stream because doing so would require all stream // access to be synchronized. It's expected that the thread using the // connection will close its streams directly. If it doesn't, the worst // case is that the GzipSource's Inflater won't be released until it's // finalized. (This logs a warning on Android.) }
@Override public final Map<String, List<String>> getHeaderFields() { try { return OkHeaders.toMultimap(getHeaders(), StatusLine.get(getResponse().getResponse()).toString()); } catch (IOException e) { return Collections.emptyMap(); } }
/** * Returns the value of the field corresponding to the {@code fieldName}, or * null if there is no such field. If the field has multiple values, the * last value is returned. */ @Override public final String getHeaderField(String fieldName) { try { return fieldName == null ? StatusLine.get(getResponse().getResponse()).toString() : getHeaders().get(fieldName); } catch (IOException e) { return null; } }
@Override protected Handshake handshake() { if (delegate.httpEngine == null) { throw new IllegalStateException("Connection has not yet been established"); } // If there's a response, get the handshake from there so that caching // works. Otherwise get the handshake from the connection because we might // have not connected yet. return delegate.httpEngine.hasResponse() ? delegate.httpEngine.getResponse().handshake() : delegate.handshake; }
@Override public final Map<String, List<String>> getRequestProperties() { if (connected) { throw new IllegalStateException( "Cannot access request header fields after connection is set"); } return OkHeaders.toMultimap(requestHeaders.build(), null); }