
io.vertx.rxjava.ext.web.client.HttpResponse Maven / Gradle / Ivy
/*
* Copyright 2014 Red Hat, Inc.
*
* Red Hat licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.vertx.rxjava.ext.web.client;
import java.util.Map;
import rx.Observable;
import rx.Single;
import io.vertx.core.json.JsonArray;
import java.util.List;
import io.vertx.rxjava.core.buffer.Buffer;
import io.vertx.core.http.HttpVersion;
import io.vertx.rxjava.core.MultiMap;
import io.vertx.core.json.JsonObject;
/**
* An HTTP response.
*
* The usual HTTP response attributes are available:
*
* - {@link io.vertx.rxjava.ext.web.client.HttpResponse#statusCode} the HTTP status code
* - {@link io.vertx.rxjava.ext.web.client.HttpResponse#statusMessage} the HTTP status message
* - {@link io.vertx.rxjava.ext.web.client.HttpResponse#headers} the HTTP headers
* - {@link io.vertx.rxjava.ext.web.client.HttpResponse#version} the HTTP version
*
*
* The body of the response is returned by {@link io.vertx.rxjava.ext.web.client.HttpResponse#body} decoded as the format specified by the that
* built the response.
*
* Keep in mind that using this HttpResponse
impose to fully buffer the response body and should be used for payload
* that can fit in memory.
*
*
* NOTE: This class has been automatically generated from the {@link io.vertx.ext.web.client.HttpResponse original} non RX-ified interface using Vert.x codegen.
*/
@io.vertx.lang.rxjava.RxGen(io.vertx.ext.web.client.HttpResponse.class)
public class HttpResponse {
public static final io.vertx.lang.rxjava.TypeArg __TYPE_ARG = new io.vertx.lang.rxjava.TypeArg<>(
obj -> new HttpResponse((io.vertx.ext.web.client.HttpResponse) obj),
HttpResponse::getDelegate
);
private final io.vertx.ext.web.client.HttpResponse delegate;
public final io.vertx.lang.rxjava.TypeArg __typeArg_0;
public HttpResponse(io.vertx.ext.web.client.HttpResponse delegate) {
this.delegate = delegate;
this.__typeArg_0 = io.vertx.lang.rxjava.TypeArg.unknown();
}
public HttpResponse(io.vertx.ext.web.client.HttpResponse delegate, io.vertx.lang.rxjava.TypeArg typeArg_0) {
this.delegate = delegate;
this.__typeArg_0 = typeArg_0;
}
public io.vertx.ext.web.client.HttpResponse getDelegate() {
return delegate;
}
/**
* @return the version of the response
*/
public HttpVersion version() {
if (cached_0 != null) {
return cached_0;
}
HttpVersion ret = delegate.version();
cached_0 = ret;
return ret;
}
/**
* @return the status code of the response
*/
public int statusCode() {
if (cached_1 != null) {
return cached_1;
}
int ret = delegate.statusCode();
cached_1 = ret;
return ret;
}
/**
* @return the status message of the response
*/
public String statusMessage() {
if (cached_2 != null) {
return cached_2;
}
String ret = delegate.statusMessage();
cached_2 = ret;
return ret;
}
/**
* @return the headers
*/
public MultiMap headers() {
if (cached_3 != null) {
return cached_3;
}
MultiMap ret = MultiMap.newInstance(delegate.headers());
cached_3 = ret;
return ret;
}
/**
* Return the first header value with the specified name
* @param headerName the header name
* @return the header value
*/
public String getHeader(String headerName) {
String ret = delegate.getHeader(headerName);
return ret;
}
/**
* @return the trailers
*/
public MultiMap trailers() {
if (cached_4 != null) {
return cached_4;
}
MultiMap ret = MultiMap.newInstance(delegate.trailers());
cached_4 = ret;
return ret;
}
/**
* Return the first trailer value with the specified name
* @param trailerName the trailer name
* @return the trailer value
*/
public String getTrailer(String trailerName) {
String ret = delegate.getTrailer(trailerName);
return ret;
}
/**
* @return the Set-Cookie headers (including trailers)
*/
public List cookies() {
if (cached_5 != null) {
return cached_5;
}
List ret = delegate.cookies();
cached_5 = ret;
return ret;
}
/**
* @return the response body in the format it was decoded.
*/
public T body() {
if (cached_6 != null) {
return cached_6;
}
T ret = (T)__typeArg_0.wrap(delegate.body());
cached_6 = ret;
return ret;
}
/**
* @return the response body decoded as a
*/
public Buffer bodyAsBuffer() {
if (cached_7 != null) {
return cached_7;
}
Buffer ret = Buffer.newInstance(delegate.bodyAsBuffer());
cached_7 = ret;
return ret;
}
/**
* @return the response body decoded as a String
*/
public String bodyAsString() {
if (cached_8 != null) {
return cached_8;
}
String ret = delegate.bodyAsString();
cached_8 = ret;
return ret;
}
/**
* @param encoding
* @return the response body decoded as a String
given a specific encoding
*/
public String bodyAsString(String encoding) {
String ret = delegate.bodyAsString(encoding);
return ret;
}
/**
* @return the response body decoded as a json object
*/
public JsonObject bodyAsJsonObject() {
if (cached_9 != null) {
return cached_9;
}
JsonObject ret = delegate.bodyAsJsonObject();
cached_9 = ret;
return ret;
}
/**
* @return the response body decoded as a json array
*/
public JsonArray bodyAsJsonArray() {
if (cached_10 != null) {
return cached_10;
}
JsonArray ret = delegate.bodyAsJsonArray();
cached_10 = ret;
return ret;
}
/**
* @param type
* @return the response body decoded as the specified type
with the Jackson mapper.
*/
public R bodyAsJson(Class type) {
R ret = (R)io.vertx.lang.rxjava.TypeArg.of(type).wrap(delegate.bodyAsJson(io.vertx.lang.rxjava.Helper.unwrap(type)));
return ret;
}
private HttpVersion cached_0;
private java.lang.Integer cached_1;
private String cached_2;
private MultiMap cached_3;
private MultiMap cached_4;
private List cached_5;
private T cached_6;
private Buffer cached_7;
private String cached_8;
private JsonObject cached_9;
private JsonArray cached_10;
public static HttpResponse newInstance(io.vertx.ext.web.client.HttpResponse arg) {
return arg != null ? new HttpResponse (arg) : null;
}
public static HttpResponse newInstance(io.vertx.ext.web.client.HttpResponse arg, io.vertx.lang.rxjava.TypeArg __typeArg_T) {
return arg != null ? new HttpResponse (arg, __typeArg_T) : null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy