@Override public void run() { if (!headers.isEmpty()) updateState(State.REQUEST); handle(); if (endRequest) performEndRequest(); } });
public void beginRequest(final Headers headers, final boolean endRequest) { this.headers = headers.isEmpty() ? null : headers; post(new Runnable() { @Override public void run() { if (!headers.isEmpty()) updateState(State.REQUEST); handle(); if (endRequest) performEndRequest(); } }); }
@Override public void messageComplete(long contentLength) throws IOException { if (stream == null) { assert content == null; if (headers.isEmpty()) proxyEngineSelector.onGoAway(session, new GoAwayInfo(0, SessionStatus.OK)); else syn(true); } else { stream.getStreamFrameListener().onData(stream, toDataInfo(content, true)); } headers.clear(); stream = null; content = null; }
@Override public StreamFrameListener onSyn(final Stream stream, SynInfo synInfo) { // Every time we have a SYN, it maps to a HTTP request. // We can have multiple concurrent SYNs on the same connection, // and this is very different from HTTP, where only one request/response // cycle is processed at a time, so we need to fake an http connection // for each SYN in order to run concurrently. logger.debug("Received {} on {}", synInfo, stream); HTTPSPDYAsyncEndPoint asyncEndPoint = new HTTPSPDYAsyncEndPoint(endPoint, stream); ServerHTTPSPDYAsyncConnection connection = new ServerHTTPSPDYAsyncConnection(connector, asyncEndPoint, connector.getServer(), getVersion(), (SPDYAsyncConnection)endPoint.getConnection(), pushStrategy, stream); asyncEndPoint.setConnection(connection); stream.setAttribute(CONNECTION_ATTRIBUTE, connection); Headers headers = synInfo.getHeaders(); connection.beginRequest(headers, synInfo.isClose()); if (headers.isEmpty()) { // If the SYN has no headers, they may come later in a HEADERS frame return this; } else { if (synInfo.isClose()) return null; else return this; } }