com.arangodb.shaded.vertx.ext.web.client.impl.HttpResponseImpl Maven / Gradle / Ivy
/*
* Copyright 2014 Red Hat, Inc.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package com.arangodb.shaded.vertx.ext.web.client.impl;
import com.arangodb.shaded.vertx.core.MultiMap;
import com.arangodb.shaded.vertx.core.buffer.Buffer;
import com.arangodb.shaded.vertx.core.http.HttpVersion;
import com.arangodb.shaded.vertx.core.json.JsonArray;
import com.arangodb.shaded.vertx.ext.web.client.HttpResponse;
import com.arangodb.shaded.vertx.ext.web.codec.impl.BodyCodecImpl;
import java.util.List;
/**
* @author Julien Viet
*/
public class HttpResponseImpl implements HttpResponse {
private final HttpVersion version;
private final int statusCode;
private final String statusMessage;
private final MultiMap headers;
private final MultiMap trailers;
private final List cookies;
private final T body;
private final List redirects;
public HttpResponseImpl(HttpVersion version,
int statusCode,
String statusMessage,
MultiMap headers,
MultiMap trailers,
List cookies,
T body, List 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 getHeader(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 cookies() {
return cookies;
}
@Override
public MultiMap headers() {
return headers;
}
@Override
public T body() {
return body;
}
@Override
public Buffer bodyAsBuffer() {
return body instanceof Buffer ? (Buffer) body : null;
}
@Override
public List followedRedirects() {
return redirects;
}
@Override
public JsonArray bodyAsJsonArray() {
Buffer b = bodyAsBuffer();
return b != null ? BodyCodecImpl.JSON_ARRAY_DECODER.apply(b) : null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy