All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.luminis.http3.core.Http3ClientConnection Maven / Gradle / Ivy

Go to download

Java implementation of HTTP3 (RFC 9114): generic client / client library and HTTP3 server plugin for Kwik.

There is a newer version: 0.5.2
Show newest version
/*
 * Copyright © 2023 Peter Doornbosch
 *
 * This file is part of Flupke, a HTTP3 client Java library
 *
 * Flupke is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or (at your option)
 * any later version.
 *
 * Flupke is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
 * more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see .
 */
package net.luminis.http3.core;

import net.luminis.http3.impl.Http3ClientConnectionImpl;
import net.luminis.http3.server.HttpError;
import net.luminis.quic.Statistics;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;

public interface Http3ClientConnection extends Http3Connection {

    static final int DEFAULT_HTTP3_PORT = 443;

    void setReceiveBufferSize(long receiveBufferSize);

    void connect() throws IOException;

     HttpResponse send(HttpRequest request, HttpResponse.BodyHandler responseBodyHandler) throws IOException;

    /**
     * Sends a CONNECT method request.
     * https://www.rfc-editor.org/rfc/rfc9114.html#name-the-connect-method:
     * "In HTTP/2 and HTTP/3, the CONNECT method is used to establish a tunnel over a single stream."
     *
     * @param request the request object; note that the HTTP method specified in this request is ignored
     * @return
     */
    Http3ClientConnectionImpl.HttpStreamImpl sendConnect(HttpRequest request) throws IOException, HttpError;

    /**
     * Sends an Extended CONNECT request (that can be used for tunneling other protocols like websocket and webtransport).
     * See https://www.rfc-editor.org/rfc/rfc9220.html and  https://www.rfc-editor.org/rfc/rfc8441.html.
     * Note that this method is only supported by servers that support Extended Connect (RFC 9220). If the server does
     * not support it, an HttpError is thrown. In any case, the client has to wait for the SETTINGS frame to be received
     * (to determine whether the server supports Extended Connect), so this method may block for a while or throw a
     * HttpError if the SETTINGS frame is not received in time.
     * @param request
     * @param protocol  the protocol to use over the tunneled connection (e.g. "websocket" or "webtransport")
     * @param scheme    "http" or "https"
     * @param settingsFrameTimeout  max time to wait for the SETTINGS frame to be received
     * @return
     * @throws IOException
     * @throws HttpError
     * @throws InterruptedException
     */
    HttpStream sendExtendedConnect(HttpRequest request, String protocol, String scheme, Duration settingsFrameTimeout) throws InterruptedException, HttpError, IOException;

    Statistics getConnectionStats();

    interface HttpStream {

        OutputStream getOutputStream();

        InputStream getInputStream();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy