package io.vertx.ext.web.client.impl;
import io.vertx.core.MultiMap;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpVersion;
import io.vertx.core.json.JsonArray;
import io.vertx.ext.web.client.HttpResponse;
import io.vertx.ext.web.codec.impl.BodyCodecImpl;
import java.util.List;
public class HttpResponseImpl<T> implements HttpResponse<T> {
private final HttpVersion version;
private final int statusCode;
private final String statusMessage;
private final MultiMap ;
private final MultiMap trailers;
private final List<String> cookies;
private final T body;
private final List<String> redirects;
public HttpResponseImpl(HttpVersion version,
int statusCode,
String statusMessage,
MultiMap headers,
MultiMap trailers,
List<String> cookies,
T body, List<String> redirects) {
this.version = version;
this.statusCode = statusCode;
this.statusMessage = statusMessage;
this.headers = headers;
this.trailers = trailers;
this.cookies = cookies;
this.body = body;
this.redirects = redirects;
}
@Override
public HttpVersion version() {
return version;
}
@Override
public int statusCode() {
return statusCode;
}
@Override
public String statusMessage() {
return statusMessage;
}
@Override
public String (String headerName) {
return headers.get(headerName);
}
@Override
public MultiMap trailers() {
return trailers;
}
@Override
public String getTrailer(String trailerName) {
return trailers.get(trailerName);
}
@Override
public List<String> cookies() {
return cookies;
}
@Override
public MultiMap () {
return headers;
}
@Override
public T body() {
return body;
}
@Override
public Buffer bodyAsBuffer() {
return body instanceof Buffer ? (Buffer) body : null;
}
@Override
public List<String> followedRedirects() {
return redirects;
}
@Override
public JsonArray bodyAsJsonArray() {
Buffer b = bodyAsBuffer();
return b != null ? BodyCodecImpl.JSON_ARRAY_DECODER.apply(b) : null;
}
}