private void pushRequestLater(final int streamId, final List<Header> requestHeaders) { synchronized (this) { if (currentPushRequests.contains(streamId)) { writeSynResetLater(streamId, ErrorCode.PROTOCOL_ERROR); return; } currentPushRequests.add(streamId); } executor.submit( new NamedRunnable("OkHttp %s Push Request[%s]", hostName, streamId) { @Override public void execute() { boolean cancel = pushObserver.onRequest(streamId, requestHeaders); try { if (cancel) { frameWriter.rstStream(streamId, ErrorCode.CANCEL); synchronized (SpdyConnection.this) { currentPushRequests.remove(streamId); } } } catch (IOException ignored) { } } }); }
/** * Abnormally terminate this stream. This enqueues a {@code RST_STREAM} frame and returns * immediately. */ public void closeLater(ErrorCode errorCode) { if (!closeInternal(errorCode)) { return; // Already closed. } connection.writeSynResetLater(id, errorCode); }