net.luminis.http3.impl.Http3Response Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of flupke Show documentation
Show all versions of flupke Show documentation
Java implementation of HTTP3 (RFC 9114): generic client / client library and HTTP3 server plugin for Kwik.
/*
* Copyright © 2019, 2020, 2021, 2022, 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.impl;
import javax.net.ssl.SSLSession;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpHeaders;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Optional;
import java.util.concurrent.CompletionStage;
public class Http3Response implements HttpResponse {
private final HttpRequest request;
private final HttpHeaders headers;
private final int statusCode;
private T body;
public Http3Response(HttpRequest request, int statusCode, HttpHeaders headers, CompletionStage bodyCompletionStage) {
this.request = request;
this.headers = headers;
this.statusCode = statusCode;
bodyCompletionStage.thenApply(t -> body = t);
}
@Override
public int statusCode() {
return statusCode;
}
@Override
public HttpRequest request() {
return request;
}
@Override
public Optional> previousResponse() {
return Optional.empty();
}
@Override
public HttpHeaders headers() {
return headers;
}
@Override
public T body() {
return body;
}
@Override
public Optional sslSession() {
return Optional.empty();
}
@Override
public URI uri() {
return null;
}
@Override
public HttpClient.Version version() {
return null;
}
@Override
public String toString() {
return String.format("(%s %s) %d", request.method(), request.uri(), statusCode);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy