public abstract class HttpResponse extends Object implements Closeable
| Constructor and Description |
|---|
HttpResponse() |
| Modifier and Type | Method and Description |
|---|---|
abstract io.reactivex.Flowable<ByteBuffer> |
body()
Returns a stream of the response's body content.
|
abstract io.reactivex.Single<byte[]> |
bodyAsByteArray()
Get this response object's body as a byte[].
|
abstract io.reactivex.Single<String> |
bodyAsString()
Get this response object's body as a string.
|
BufferedHttpResponse |
buffer()
Buffers the HTTP response body into memory, allowing the content to be inspected and replayed.
|
void |
close()
Closes the stream providing this HttpResponse's content, if any.
|
Object |
deserializedBody() |
Object |
deserializedHeaders() |
abstract HttpHeaders |
headers()
Get all the headers on this HTTP response.
|
abstract String |
headerValue(String headerName)
Get the header value for the provided header name, or null if the provided header name does
not appear in this HttpResponse's headers.
|
boolean |
isDecoded()
Returns a value indicating whether this HttpResponse has been decoded by a
DecodingPolicyFactory. |
HttpRequest |
request() |
abstract int |
statusCode()
Get this response object's HTTP status code.
|
HttpResponse |
withDeserializedBody(Object deserializedBody)
Sets the deserialized body on this HttpResponse.
|
HttpResponse |
withDeserializedHeaders(Object deserializedHeaders)
Set the deserialized headers on this HttpResponse.
|
boolean |
withIsDecoded(boolean isDecoded)
Sets the flag indicating whether this HttpResponse has been decoded by a
DecodingPolicyFactory. |
HttpResponse |
withRequest(HttpRequest request)
Sets the request on this HttpResponse.
|
public abstract int statusCode()
public abstract String headerValue(String headerName)
headerName - The name of the header to lookup.public abstract HttpHeaders headers()
public abstract io.reactivex.Flowable<ByteBuffer> body()
Returns a stream of the response's body content. Emissions may occur on the
Netty EventLoop threads which are shared across channels and should not be
blocked. Blocking should be avoided as much as possible/practical in reactive
programming but if you do use methods like blockingSubscribe or blockingGet
on the stream then be sure to use subscribeOn and observeOn
before the blocking call. For example:
response.body()
.map(bb -> bb.limit())
.reduce((x,y) -> x + y)
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
.blockingGet();
The above code is a simplistic example and would probably run fine without the `subscribeOn` and `observeOn` but should be considered a template for more complex situations.
ByteBuffer.public abstract io.reactivex.Single<byte[]> bodyAsByteArray()
public abstract io.reactivex.Single<String> bodyAsString()
public BufferedHttpResponse buffer()
public void close()
close in interface Closeableclose in interface AutoCloseablepublic boolean isDecoded()
DecodingPolicyFactory.public boolean withIsDecoded(boolean isDecoded)
DecodingPolicyFactory.isDecoded - whether this HttpResponse has been decodedpublic Object deserializedHeaders()
public HttpResponse withDeserializedHeaders(Object deserializedHeaders)
deserializedHeaders - the deserialized headerspublic Object deserializedBody()
public HttpResponse withDeserializedBody(Object deserializedBody)
deserializedBody - the deserialized bodypublic final HttpRequest request()
public final HttpResponse withRequest(HttpRequest request)
request - the request which resulted in this HttpResponse/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/