Class HTTP3Client
- All Implemented Interfaces:
 AutoCloseable, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle
HTTP3Client provides an asynchronous, non-blocking implementation to send HTTP/3 frames to a server.
Typical usage:
// Client-side QUIC configuration to configure QUIC properties.
QuicheClientQuicConfiguration clientQuicConfig = HTTP3ClientQuicConfiguration.configure(new QuicheClientQuicConfiguration());
// Create the HTTP3Client instance.
HTTP3Client http3Client = new HTTP3Client(clientQuicConfig);
// To configure HTTP/3 properties.
HTTP3Configuration h3Config = http3Client.getHTTP3Configuration();
http3Client.start();
// HTTP3Client request/response usage.
// Connect to host.
String host = "jetty.org";
int port = 443;
Session.Client session = Blocker.blockWithPromise(p -> http3Client
    .connect(new QuicheTransport(clientQuicConfig), new InetSocketAddress(host, port), new Session.Client.Listener() {}, p));
// Prepare the HTTP request headers.
HttpFields.Mutable requestFields = HttpFields.build();
requestFields.put("User-Agent", http3Client.getClass().getName() + "/" + Jetty.VERSION);
// Prepare the HTTP request object.
MetaData.Request request = new MetaData.Request("PUT", HttpURI.from("https://" + host + ":" + port + "/"), HttpVersion.HTTP_3, requestFields);
// Create the HTTP/3 HEADERS frame representing the HTTP request.
HeadersFrame headersFrame = new HeadersFrame(request, false);
// Send the HEADERS frame to create a request stream.
Stream.Client stream = Blocker.blockWithPromise(p -> session.newRequest(headersFrame, new Stream.Client.Listener()
{
    @Override
    public void onResponse(Stream.Client stream, HeadersFrame frame)
    {
        // Inspect the response status and headers.
        MetaData.Response response = (MetaData.Response)frame.getMetaData();
        // Demand for response content.
        stream.demand();
    }
    @Override
    public void onDataAvailable(Stream.Client stream)
    {
        Content.Chunk chunk = stream.read();
        if (chunk == null)
        {
            stream.demand();
            return;
        }
        // Process the response content chunk.
        process(chunk);
        // Release the chunk.
        chunk.release();
        // Demand for more response content.
        if (!chunk.isLast())
            stream.demand();
    }
}, p));
// Use the Stream.Client object to send request content, if any, using a DATA frame.
ByteBuffer requestChunk1 = UTF_8.encode("hello");
stream.data(new DataFrame(requestChunk1, false), new Promise.Invocable.NonBlocking()
{
    @Override
    public void succeeded(Stream s)
    {
        // Subsequent sends must wait for previous sends to complete.
        ByteBuffer requestChunk2 = UTF_8.encode("world");
        return s.data(new DataFrame(requestChunk2, true), Promise.Invocable.noop());
    }
});
IMPLEMENTATION NOTES.
Each call to connect(Transport, SocketAddress, Session.Client.Listener, Promise.Invocable)
creates a new DatagramChannelEndPoint with the correspondent QUIC
Connection.
Each QUIC connection manages one QUIC Session
with the corresponding ClientHTTP3Session.
Each ClientHTTP3Session manages the mandatory QPACK encoder, QPACK decoder
and control unidirectional streams, plus zero or more request/response bidirectional
streams.
GENERIC, TCP-LIKE, SETUP FOR HTTP/1.1 AND HTTP/2
HTTP3Client - dgramEP - QUIC Connection - QUIC Session - ClientProtocolSession - TCPLikeStream
SPECIFIC SETUP FOR HTTP/3
                                                                            ,- [Control|Decoder|Encoder]Stream
HTTP3Client - dgramEP - QUIC Connection - QUIC Session - ClientHTTP3Session -* HTTP3Streams
HTTP/3+QUIC support is experimental and not suited for production use. APIs may change incompatibly between releases.
- 
Nested Class Summary
Nested classes/interfaces inherited from class AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopExceptionNested classes/interfaces inherited from interface Container
Container.InheritedListener, Container.ListenerNested classes/interfaces inherited from interface Dumpable
Dumpable.DumpableContainer, Dumpable.DumpAppendableNested classes/interfaces inherited from interface LifeCycle
LifeCycle.Listener - 
Field Summary
Fields - 
Constructor Summary
ConstructorsConstructorDescriptionHTTP3Client(ClientQuicConfiguration quicConfiguration) HTTP3Client(ClientQuicConfiguration quicConfiguration, ClientConnector connector)  - 
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidconnect(Transport transport, SocketAddress socketAddress, Session.Client.Listener listener, Promise.Invocable<Session.Client> promise) Connect for HTTP/3, clear-text or intrinsically secure depending on theTransport.voidconnect(Transport transport, SslContextFactory.Client sslContextFactory, SocketAddress socketAddress, Session.Client.Listener listener, Map<String, Object> context, Promise.Invocable<Session.Client> promise) voidconnect(Transport transport, SslContextFactory.Client sslContextFactory, SocketAddress socketAddress, Session.Client.Listener listener, Promise.Invocable<Session.Client> promise) Connect for HTTP/3, clear-text, or secure, or intrinsically secure depending on theTransport.protected voiddoStart()Starts the managed lifecycle beans in the order they were added.booleanvoidsetApplicationProtocols(List<String> protocols) voidsetUseALPN(boolean useALPN) shutdown()Methods inherited from class ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, destroy, doStop, dump, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, installBean, installBean, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeansMethods inherited from class AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop, toStringMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Container
getCachedBeans, getEventListenersMethods inherited from interface Dumpable.DumpableContainer
isDumpable 
- 
Field Details
- 
CONTEXT_KEY
 - 
SESSION_PROMISE_CONTEXT_KEY
 - 
SESSION_LISTENER_CONTEXT_KEY
 
 - 
 - 
Constructor Details
- 
HTTP3Client
 - 
HTTP3Client
 
 - 
 - 
Method Details
- 
getHTTP3Configuration
 - 
getClientQuicConfiguration
 - 
getClientConnector
 - 
getApplicationProtocols
 - 
setApplicationProtocols
 - 
isUseALPN
public boolean isUseALPN() - 
setUseALPN
public void setUseALPN(boolean useALPN)  - 
doStart
Description copied from class:ContainerLifeCycleStarts the managed lifecycle beans in the order they were added.- Overrides:
 doStartin classContainerLifeCycle- Throws:
 Exception- If there was a problem starting. Will cause a transition to FAILED state
 - 
connect
public void connect(Transport transport, SocketAddress socketAddress, Session.Client.Listener listener, Promise.Invocable<Session.Client> promise) Connect for HTTP/3, clear-text or intrinsically secure depending on the
Transport.- Parameters:
 transport- theTransportto usesocketAddress- the address to connect tolistener- the listener to notify of session eventspromise- aPromise.Invocablethat is completed when the connect operation is complete
 - 
connect
public void connect(Transport transport, SslContextFactory.Client sslContextFactory, SocketAddress socketAddress, Session.Client.Listener listener, Promise.Invocable<Session.Client> promise) Connect for HTTP/3, clear-text, or secure, or intrinsically secure depending on the
Transport.- Parameters:
 transport- theTransportto usesslContextFactory-nullfor clear-text, non-nullfor secure HTTP/3socketAddress- the address to connect tolistener- the listener to notify of session eventspromise- aPromise.Invocablethat is completed when the connect operation is complete
 - 
connect
public void connect(Transport transport, SslContextFactory.Client sslContextFactory, SocketAddress socketAddress, Session.Client.Listener listener, Map<String, Object> context, Promise.Invocable<Session.Client> promise)  - 
shutdown
 - 
close
- Specified by:
 closein interfaceAutoCloseable- Throws:
 Exception
 
 -