use of org.apache.hc.core5.reactor.ssl.TlsDetails in project httpcomponents-core by apache.
the class ClientH2PrefaceHandler method initialize.
private void initialize() throws IOException {
final TlsDetails tlsDetails = ioSession.getTlsDetails();
if (tlsDetails != null) {
final String applicationProtocol = tlsDetails.getApplicationProtocol();
if (TextUtils.isEmpty(applicationProtocol)) {
if (strictALPNHandshake) {
throw new ProtocolNegotiationException("ALPN: missing application protocol");
}
} else {
if (!ApplicationProtocol.HTTP_2.id.equals(applicationProtocol)) {
throw new ProtocolNegotiationException("ALPN: unexpected application protocol '" + applicationProtocol + "'");
}
}
}
this.preface = ByteBuffer.wrap(PREFACE);
ioSession.setEvent(SelectionKey.OP_WRITE);
}
use of org.apache.hc.core5.reactor.ssl.TlsDetails in project httpcomponents-core by apache.
the class ServerHttp1UpgradeHandler method upgrade.
@Override
public void upgrade(final ProtocolIOSession ioSession, final FutureCallback<ProtocolIOSession> callback) {
final TlsDetails tlsDetails = ioSession.getTlsDetails();
final ServerHttp1IOEventHandler eventHandler = new ServerHttp1IOEventHandler(http1StreamHandlerFactory.create(tlsDetails != null ? URIScheme.HTTPS.id : URIScheme.HTTP.id, ioSession));
ioSession.upgrade(eventHandler);
ioSession.upgrade(eventHandler);
try {
eventHandler.connected(ioSession);
if (callback != null) {
callback.completed(ioSession);
}
} catch (final IOException ex) {
eventHandler.exception(ioSession, ex);
}
}
use of org.apache.hc.core5.reactor.ssl.TlsDetails in project httpcomponents-core by apache.
the class HttpProtocolNegotiator method connected.
@Override
public void connected(final IOSession session) throws IOException {
final HttpVersion httpVersion;
final TlsDetails tlsDetails = ioSession.getTlsDetails();
if (tlsDetails != null) {
final String appProtocol = tlsDetails.getApplicationProtocol();
if (TextUtils.isEmpty(appProtocol)) {
httpVersion = HttpVersion.HTTP_1_1;
} else if (appProtocol.equals(ApplicationProtocol.HTTP_1_1.id)) {
httpVersion = HttpVersion.HTTP_1_1;
} else if (appProtocol.equals(ApplicationProtocol.HTTP_2.id)) {
httpVersion = HttpVersion.HTTP_2;
} else {
throw new ProtocolNegotiationException("Unsupported application protocol: " + appProtocol);
}
} else {
httpVersion = HttpVersion.HTTP_1_1;
}
startProtocol(httpVersion);
}
Aggregations