in httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/ServerHttp1StreamDuplexer.java [94:187]
public ServerHttp1StreamDuplexer(
final ProtocolIOSession ioSession,
final HttpProcessor httpProcessor,
final HandlerFactory<AsyncServerExchangeHandler> exchangeHandlerFactory,
final String scheme,
final Http1Config http1Config,
final CharCodingConfig charCodingConfig,
final ConnectionReuseStrategy connectionReuseStrategy,
final NHttpMessageParser<HttpRequest> incomingMessageParser,
final NHttpMessageWriter<HttpResponse> outgoingMessageWriter,
final ContentLengthStrategy incomingContentStrategy,
final ContentLengthStrategy outgoingContentStrategy,
final Http1StreamListener streamListener) {
super(ioSession, http1Config, charCodingConfig, incomingMessageParser, outgoingMessageWriter,
incomingContentStrategy, outgoingContentStrategy);
this.httpProcessor = Args.notNull(httpProcessor, "HTTP processor");
this.exchangeHandlerFactory = Args.notNull(exchangeHandlerFactory, "Exchange handler factory");
this.scheme = scheme;
this.http1Config = http1Config != null ? http1Config : Http1Config.DEFAULT;
this.connectionReuseStrategy = connectionReuseStrategy != null ? connectionReuseStrategy :
DefaultConnectionReuseStrategy.INSTANCE;
this.streamListener = streamListener;
this.pipeline = new ConcurrentLinkedQueue<>();
this.outputChannel = new Http1StreamChannel<HttpResponse>() {
@Override
public void close() {
ServerHttp1StreamDuplexer.this.close(CloseMode.GRACEFUL);
}
@Override
public void submit(
final HttpResponse response,
final boolean endStream,
final FlushMode flushMode) throws HttpException, IOException {
if (streamListener != null) {
streamListener.onResponseHead(ServerHttp1StreamDuplexer.this, response);
}
commitMessageHead(response, endStream, flushMode);
}
@Override
public void requestOutput() {
requestSessionOutput();
}
@Override
public void suspendOutput() throws IOException {
suspendSessionOutput();
}
@Override
public Timeout getSocketTimeout() {
return getSessionTimeout();
}
@Override
public void setSocketTimeout(final Timeout timeout) {
setSessionTimeout(timeout);
}
@Override
public int write(final ByteBuffer src) throws IOException {
return streamOutput(src);
}
@Override
public void complete(final List<? extends Header> trailers) throws IOException {
endOutputStream(trailers);
}
@Override
public boolean isCompleted() {
return isOutputCompleted();
}
@Override
public boolean abortGracefully() throws IOException {
final MessageDelineation messageDelineation = endOutputStream(null);
return messageDelineation != MessageDelineation.MESSAGE_HEAD;
}
@Override
public void activate() throws HttpException, IOException {
// empty
}
@Override
public String toString() {
return "Http1StreamChannel[" + ServerHttp1StreamDuplexer.this + "]";
}
};
}