Top Description Inners Constructors Methods
org.xnio.http

public Class HttpUpgrade

extends Object
Class Inheritance
Static Imports
org.xnio.IoUtils.safeClose, org.xnio._private.Messages.msg

Simple HTTP client that can perform a HTTP upgrade. This is not a general purpose HTTP client, all it can do is upgrade a HTTP
Author
Stuart Douglas

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static IoFuture<SslConnection>

Returns:

An IoFuture of the connection
performUpgrade
(final XnioWorker
The worker
worker
,
XnioSsl
The XnioSsl instance
ssl
,
InetSocketAddress
The bind address
bindAddress
,
URI
The URI to connect to
uri
,
final Map<String, String>
Any additional headers to include in the upgrade request. This must include an Upgrade header that specifies the type of upgrade being performed
headers
,
ChannelListener<? super SslConnection>
The open listener that is invoked once the HTTP upgrade is done
openListener
,
ChannelListener<? super BoundChannel>
The bind listener that is invoked when the socket is bound
bindListener
,
OptionMap
The option map for the connection
optionMap
,
HandshakeChecker
A handshake checker that can be supplied to verify that the server returned a valid response to the upgrade request
handshakeChecker
)

Perform a HTTP upgrade that results in a SSL secured connection.

public static IoFuture<SslConnection>

Returns:

An IoFuture of the connection
performUpgrade
(final XnioWorker
The worker
worker
,
XnioSsl
The XnioSsl instance
ssl
,
InetSocketAddress
The bind address
bindAddress
,
URI
The URI to connect to
uri
,
final Map<String, List<String>>
Any additional headers to include in the upgrade request. This must include an Upgrade header that specifies the type of upgrade being performed
headers
,
ChannelListener<? super SslConnection>
The open listener that is invoked once the HTTP upgrade is done
openListener
,
ChannelListener<? super BoundChannel>
The bind listener that is invoked when the socket is bound
bindListener
,
OptionMap
The option map for the connection
optionMap
,
ExtendedHandshakeChecker
A handshake checker that can be supplied to verify that the server returned a valid response to the upgrade request
handshakeChecker
)

Perform a HTTP upgrade that results in a SSL secured connection.

public static IoFuture<StreamConnection>

Returns:

An IoFuture of the connection
performUpgrade
(final XnioWorker
The worker
worker
,
InetSocketAddress
The bind address
bindAddress
,
URI
The URI to connect to
uri
,
final Map<String, String>
Any additional headers to include in the upgrade request. This must include an Upgrade header that specifies the type of upgrade being performed
headers
,
ChannelListener<? super StreamConnection>
The open listener that is invoked once the HTTP upgrade is done
openListener
,
ChannelListener<? super BoundChannel>
The bind listener that is invoked when the socket is bound
bindListener
,
OptionMap
The option map for the connection
optionMap
,
HandshakeChecker
A handshake checker that can be supplied to verify that the server returned a valid response to the upgrade request
handshakeChecker
)

Connects to the target server using HTTP upgrade.

public static IoFuture<StreamConnection>

Returns:

An IoFuture of the connection
performUpgrade
(final XnioWorker
The worker
worker
,
InetSocketAddress
The bind address
bindAddress
,
URI
The URI to connect to
uri
,
final Map<String, List<String>>
Any additional headers to include in the upgrade request. This must include an Upgrade header that specifies the type of upgrade being performed
headers
,
ChannelListener<? super StreamConnection>
The open listener that is invoked once the HTTP upgrade is done
openListener
,
ChannelListener<? super BoundChannel>
The bind listener that is invoked when the socket is bound
bindListener
,
OptionMap
The option map for the connection
optionMap
,
ExtendedHandshakeChecker
A handshake checker that can be supplied to verify that the server returned a valid response to the upgrade request
handshakeChecker
)

Connects to the target server using HTTP upgrade.

public static <T extends StreamConnection> IoFuture<T>

Returns:

An IoFuture of the connection
performUpgrade
(final T
The existing connection to upgrade
connection
,
URI
The URI to connect to
uri
,
final Map<String, String>
Any additional headers to include in the upgrade request. This must include an Upgrade header that specifies the type of upgrade being performed
headers
,
ChannelListener<? super StreamConnection>
The open listener that is invoked once the HTTP upgrade is done
openListener
,
HandshakeChecker
A handshake checker that can be supplied to verify that the server returned a valid response to the upgrade request
handshakeChecker
)

Performs a HTTP upgrade on an existing connection.

public static <T extends StreamConnection> IoFuture<T>

Returns:

An IoFuture of the connection
performUpgrade
(final T
The existing connection to upgrade
connection
,
URI
The URI to connect to
uri
,
final Map<String, List<String>>
Any additional headers to include in the upgrade request. This must include an Upgrade header that specifies the type of upgrade being performed
headers
,
ChannelListener<? super StreamConnection>
The open listener that is invoked once the HTTP upgrade is done
openListener
,
ExtendedHandshakeChecker
A handshake checker that can be supplied to verify that the server returned a valid response to the upgrade request
handshakeChecker
)

Performs a HTTP upgrade on an existing connection.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

HttpUpgradeback to summary
private HttpUpgrade()

Method Detail

performUpgradeback to summary
public static IoFuture<SslConnection> performUpgrade(final XnioWorker worker, XnioSsl ssl, InetSocketAddress bindAddress, URI uri, final Map<String, String> headers, ChannelListener<? super SslConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap, HandshakeChecker handshakeChecker)

Perform a HTTP upgrade that results in a SSL secured connection. This method should be used if the target endpoint is using https

Parameters
worker:XnioWorker

The worker

ssl:XnioSsl

The XnioSsl instance

bindAddress:InetSocketAddress

The bind address

uri:URI

The URI to connect to

headers:Map<String, String>

Any additional headers to include in the upgrade request. This must include an Upgrade header that specifies the type of upgrade being performed

openListener:ChannelListener<? super SslConnection>

The open listener that is invoked once the HTTP upgrade is done

bindListener:ChannelListener<? super BoundChannel>

The bind listener that is invoked when the socket is bound

optionMap:OptionMap

The option map for the connection

handshakeChecker:HandshakeChecker

A handshake checker that can be supplied to verify that the server returned a valid response to the upgrade request

Returns:IoFuture<SslConnection>

An IoFuture of the connection

performUpgradeback to summary
public static IoFuture<SslConnection> performUpgrade(final XnioWorker worker, XnioSsl ssl, InetSocketAddress bindAddress, URI uri, final Map<String, List<String>> headers, ChannelListener<? super SslConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap, ExtendedHandshakeChecker handshakeChecker)

Perform a HTTP upgrade that results in a SSL secured connection. This method should be used if the target endpoint is using https

Parameters
worker:XnioWorker

The worker

ssl:XnioSsl

The XnioSsl instance

bindAddress:InetSocketAddress

The bind address

uri:URI

The URI to connect to

headers:Map<String, List<String>>

Any additional headers to include in the upgrade request. This must include an Upgrade header that specifies the type of upgrade being performed

openListener:ChannelListener<? super SslConnection>

The open listener that is invoked once the HTTP upgrade is done

bindListener:ChannelListener<? super BoundChannel>

The bind listener that is invoked when the socket is bound

optionMap:OptionMap

The option map for the connection

handshakeChecker:ExtendedHandshakeChecker

A handshake checker that can be supplied to verify that the server returned a valid response to the upgrade request

Returns:IoFuture<SslConnection>

An IoFuture of the connection

performUpgradeback to summary
public static IoFuture<StreamConnection> performUpgrade(final XnioWorker worker, InetSocketAddress bindAddress, URI uri, final Map<String, String> headers, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap, HandshakeChecker handshakeChecker)

Connects to the target server using HTTP upgrade.

Parameters
worker:XnioWorker

The worker

bindAddress:InetSocketAddress

The bind address

uri:URI

The URI to connect to

headers:Map<String, String>

Any additional headers to include in the upgrade request. This must include an Upgrade header that specifies the type of upgrade being performed

openListener:ChannelListener<? super StreamConnection>

The open listener that is invoked once the HTTP upgrade is done

bindListener:ChannelListener<? super BoundChannel>

The bind listener that is invoked when the socket is bound

optionMap:OptionMap

The option map for the connection

handshakeChecker:HandshakeChecker

A handshake checker that can be supplied to verify that the server returned a valid response to the upgrade request

Returns:IoFuture<StreamConnection>

An IoFuture of the connection

performUpgradeback to summary
public static IoFuture<StreamConnection> performUpgrade(final XnioWorker worker, InetSocketAddress bindAddress, URI uri, final Map<String, List<String>> headers, ChannelListener<? super StreamConnection> openListener, ChannelListener<? super BoundChannel> bindListener, OptionMap optionMap, ExtendedHandshakeChecker handshakeChecker)

Connects to the target server using HTTP upgrade.

Parameters
worker:XnioWorker

The worker

bindAddress:InetSocketAddress

The bind address

uri:URI

The URI to connect to

headers:Map<String, List<String>>

Any additional headers to include in the upgrade request. This must include an Upgrade header that specifies the type of upgrade being performed

openListener:ChannelListener<? super StreamConnection>

The open listener that is invoked once the HTTP upgrade is done

bindListener:ChannelListener<? super BoundChannel>

The bind listener that is invoked when the socket is bound

optionMap:OptionMap

The option map for the connection

handshakeChecker:ExtendedHandshakeChecker

A handshake checker that can be supplied to verify that the server returned a valid response to the upgrade request

Returns:IoFuture<StreamConnection>

An IoFuture of the connection

performUpgradeback to summary
public static <T extends StreamConnection> IoFuture<T> performUpgrade(final T connection, URI uri, final Map<String, String> headers, ChannelListener<? super StreamConnection> openListener, HandshakeChecker handshakeChecker)

Performs a HTTP upgrade on an existing connection.

Parameters
connection:T

The existing connection to upgrade

uri:URI

The URI to connect to

headers:Map<String, String>

Any additional headers to include in the upgrade request. This must include an Upgrade header that specifies the type of upgrade being performed

openListener:ChannelListener<? super StreamConnection>

The open listener that is invoked once the HTTP upgrade is done

handshakeChecker:HandshakeChecker

A handshake checker that can be supplied to verify that the server returned a valid response to the upgrade request

Returns:IoFuture<T>

An IoFuture of the connection

performUpgradeback to summary
public static <T extends StreamConnection> IoFuture<T> performUpgrade(final T connection, URI uri, final Map<String, List<String>> headers, ChannelListener<? super StreamConnection> openListener, ExtendedHandshakeChecker handshakeChecker)

Performs a HTTP upgrade on an existing connection.

Parameters
connection:T

The existing connection to upgrade

uri:URI

The URI to connect to

headers:Map<String, List<String>>

Any additional headers to include in the upgrade request. This must include an Upgrade header that specifies the type of upgrade being performed

openListener:ChannelListener<? super StreamConnection>

The open listener that is invoked once the HTTP upgrade is done

handshakeChecker:ExtendedHandshakeChecker

A handshake checker that can be supplied to verify that the server returned a valid response to the upgrade request

Returns:IoFuture<T>

An IoFuture of the connection

org.xnio.http back to summary

private Class HttpUpgrade.HttpUpgradeState<T extends StreamConnection>

extends Object
Class Inheritance

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class
private class
private class

Field Summary

Modifier and TypeField and Description
private final InetSocketAddress
private final ChannelListener<? super BoundChannel>
private T
private final FutureResult<T>
private final Object
private final Map<String, List<String>>
private final ChannelListener<? super T>
private final OptionMap
private final XnioSsl
private final URI
private final XnioWorker

Constructor Summary

AccessConstructor and Description
private
HttpUpgradeState(final XnioWorker worker, final XnioSsl ssl, final InetSocketAddress bindAddress, final URI uri, final Map<String, String> headers, final ChannelListener<? super T> openListener, final ChannelListener<? super BoundChannel> bindListener, final OptionMap optionMap, final HandshakeChecker handshakeChecker)

private
HttpUpgradeState(final XnioWorker worker, final XnioSsl ssl, final InetSocketAddress bindAddress, final URI uri, final Map<String, List<String>> headers, final ChannelListener<? super T> openListener, final ChannelListener<? super BoundChannel> bindListener, final OptionMap optionMap, final ExtendedHandshakeChecker handshakeChecker)

public
HttpUpgradeState(final T connection, final URI uri, final Map<String, String> headers, final ChannelListener<? super StreamConnection> openListener, final HandshakeChecker handshakeChecker)

public
HttpUpgradeState(final T connection, final URI uri, final Map<String, List<String>> headers, final ChannelListener<? super StreamConnection> openListener, final ExtendedHandshakeChecker handshakeChecker)

Method Summary

Modifier and TypeMethod and Description
private String
private IoFuture<T>
private void
private String
private void
private void
public IoFuture<T>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bindAddressback to summary
private final InetSocketAddress bindAddress
bindListenerback to summary
private final ChannelListener<? super BoundChannel> bindListener
connectionback to summary
private T connection
futureback to summary
private final FutureResult<T> future
handshakeCheckerback to summary
private final Object handshakeChecker
headersback to summary
private final Map<String, List<String>> headers
openListenerback to summary
private final ChannelListener<? super T> openListener
optionMapback to summary
private final OptionMap optionMap
sslback to summary
private final XnioSsl ssl
uriback to summary
private final URI uri
workerback to summary
private final XnioWorker worker

Constructor Detail

HttpUpgradeStateback to summary
private HttpUpgradeState(final XnioWorker worker, final XnioSsl ssl, final InetSocketAddress bindAddress, final URI uri, final Map<String, String> headers, final ChannelListener<? super T> openListener, final ChannelListener<? super BoundChannel> bindListener, final OptionMap optionMap, final HandshakeChecker handshakeChecker)
HttpUpgradeStateback to summary
private HttpUpgradeState(final XnioWorker worker, final XnioSsl ssl, final InetSocketAddress bindAddress, final URI uri, final Map<String, List<String>> headers, final ChannelListener<? super T> openListener, final ChannelListener<? super BoundChannel> bindListener, final OptionMap optionMap, final ExtendedHandshakeChecker handshakeChecker)
HttpUpgradeStateback to summary
public HttpUpgradeState(final T connection, final URI uri, final Map<String, String> headers, final ChannelListener<? super StreamConnection> openListener, final HandshakeChecker handshakeChecker)
HttpUpgradeStateback to summary
public HttpUpgradeState(final T connection, final URI uri, final Map<String, List<String>> headers, final ChannelListener<? super StreamConnection> openListener, final ExtendedHandshakeChecker handshakeChecker)

Method Detail

buildHttpRequestback to summary
private String buildHttpRequest()
doUpgradeback to summary
private IoFuture<T> doUpgrade()
flushUpgradeChannelback to summary
private void flushUpgradeChannel()
getHostback to summary
private String getHost()
handleRedirectback to summary
private void handleRedirect(final HttpUpgradeParser parser)
handleUpgradeback to summary
private void handleUpgrade(final HttpUpgradeParser parser)
upgradeExistingConnectionback to summary
public IoFuture<T> upgradeExistingConnection()
org.xnio.http back to summary

private Class HttpUpgrade.HttpUpgradeState.ConnectionOpenListener

extends Object
implements ChannelListener<StreamConnection>
Class Inheritance
  • java.lang.Object
  • org.xnio.http.HttpUpgrade.HttpUpgradeState.ConnectionOpenListener
All Implemented Interfaces
org.xnio.ChannelListener, java.util.EventListener

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
handleEvent(final StreamConnection
the channel event
channel
)

Implements org.xnio.ChannelListener.handleEvent.

Handle the event on this channel.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ConnectionOpenListenerback to summary
private ConnectionOpenListener()

Method Detail

handleEventback to summary
public void handleEvent(final StreamConnection channel)

Implements org.xnio.ChannelListener.handleEvent.

Doc from org.xnio.ChannelListener.handleEvent.

Handle the event on this channel.

Parameters
channel:StreamConnection

the channel event

Annotations
@Override
org.xnio.http back to summary

private Class HttpUpgrade.HttpUpgradeState.FailureNotifier

extends IoFuture.HandlingNotifier<StreamConnection, Object>
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
handleCancelled(Object
the attachment
attachment
)

Overrides org.xnio.IoFuture.HandlingNotifier.handleCancelled.

Handle cancellation.

public void
handleFailed(IOException
the failure reason
exception
,
Object
the attachment
attachment
)

Overrides org.xnio.IoFuture.HandlingNotifier.handleFailed.

Handle failure.

Inherited from org.xnio.IoFuture.HandlingNotifier:
handleDonenotify

Constructor Detail

FailureNotifierback to summary
private FailureNotifier()

Method Detail

handleCancelledback to summary
public void handleCancelled(Object attachment)

Overrides org.xnio.IoFuture.HandlingNotifier.handleCancelled.

Doc from org.xnio.IoFuture.HandlingNotifier.handleCancelled.

Handle cancellation.

Parameters
attachment:Object

the attachment

Annotations
@Override
handleFailedback to summary
public void handleFailed(IOException exception, Object attachment)

Overrides org.xnio.IoFuture.HandlingNotifier.handleFailed.

Doc from org.xnio.IoFuture.HandlingNotifier.handleFailed.

Handle failure.

Parameters
exception:IOException

the failure reason

attachment:Object

the attachment

Annotations
@Override
org.xnio.http back to summary

private final Class HttpUpgrade.HttpUpgradeState.StringWriteListener

extends Object
implements ChannelListener<StreamSinkChannel>
Class Inheritance
  • java.lang.Object
  • org.xnio.http.HttpUpgrade.HttpUpgradeState.StringWriteListener
All Implemented Interfaces
org.xnio.ChannelListener, java.util.EventListener

Field Summary

Modifier and TypeField and Description
pack-priv final ByteBuffer

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
handleEvent(final StreamSinkChannel
the channel event
channel
)

Implements org.xnio.ChannelListener.handleEvent.

Handle the event on this channel.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufferback to summary
pack-priv final ByteBuffer buffer

Constructor Detail

StringWriteListenerback to summary
private StringWriteListener(final ByteBuffer buffer)

Method Detail

handleEventback to summary
public void handleEvent(final StreamSinkChannel channel)

Implements org.xnio.ChannelListener.handleEvent.

Doc from org.xnio.ChannelListener.handleEvent.

Handle the event on this channel.

Parameters
channel:StreamSinkChannel

the channel event

Annotations
@Override
org.xnio.http back to summary

private final Class HttpUpgrade.HttpUpgradeState.UpgradeResultListener

extends Object
implements ChannelListener<StreamSourceChannel>
Class Inheritance
  • java.lang.Object
  • org.xnio.http.HttpUpgrade.HttpUpgradeState.UpgradeResultListener
All Implemented Interfaces
org.xnio.ChannelListener, java.util.EventListener

Field Summary

Modifier and TypeField and Description
private ByteBuffer
private final HttpUpgradeParser

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
handleEvent(final StreamSourceChannel
the channel event
channel
)

Implements org.xnio.ChannelListener.handleEvent.

Handle the event on this channel.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bufferback to summary
private ByteBuffer buffer
parserback to summary
private final HttpUpgradeParser parser

Constructor Detail

UpgradeResultListenerback to summary
private UpgradeResultListener()

Method Detail

handleEventback to summary
public void handleEvent(final StreamSourceChannel channel)

Implements org.xnio.ChannelListener.handleEvent.

Doc from org.xnio.ChannelListener.handleEvent.

Handle the event on this channel.

Parameters
channel:StreamSourceChannel

the channel event

Annotations
@Override