public final class BufferedHttpResponse extends HttpResponse
| Constructor and Description |
|---|
BufferedHttpResponse(HttpResponse innerHttpResponse)
Creates a buffered HTTP response.
|
| Modifier and Type | Method and Description |
|---|---|
io.reactivex.Flowable<ByteBuffer> |
body()
Returns a stream of the response's body content.
|
io.reactivex.Single<byte[]> |
bodyAsByteArray()
Get this response object's body as a byte[].
|
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.
|
Object |
deserializedBody() |
Object |
deserializedHeaders() |
HttpHeaders |
headers()
Get all the headers on this HTTP response.
|
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. |
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. |
close, request, withRequestpublic BufferedHttpResponse(HttpResponse innerHttpResponse)
innerHttpResponse - The HTTP response to buffer.public int statusCode()
HttpResponsestatusCode in class HttpResponsepublic String headerValue(String headerName)
HttpResponseheaderValue in class HttpResponseheaderName - The name of the header to lookup.public HttpHeaders headers()
HttpResponseheaders in class HttpResponsepublic io.reactivex.Single<byte[]> bodyAsByteArray()
HttpResponsebodyAsByteArray in class HttpResponsepublic io.reactivex.Flowable<ByteBuffer> body()
HttpResponse
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.
body in class HttpResponseByteBuffer.public io.reactivex.Single<String> bodyAsString()
HttpResponsebodyAsString in class HttpResponsepublic BufferedHttpResponse buffer()
HttpResponsebuffer in class HttpResponsepublic boolean isDecoded()
HttpResponseDecodingPolicyFactory.isDecoded in class HttpResponsepublic boolean withIsDecoded(boolean isDecoded)
HttpResponseDecodingPolicyFactory.withIsDecoded in class HttpResponseisDecoded - whether this HttpResponse has been decodedpublic Object deserializedHeaders()
deserializedHeaders in class HttpResponsepublic HttpResponse withDeserializedHeaders(Object deserializedHeaders)
HttpResponsewithDeserializedHeaders in class HttpResponsedeserializedHeaders - the deserialized headerspublic Object deserializedBody()
deserializedBody in class HttpResponsepublic HttpResponse withDeserializedBody(Object deserializedBody)
HttpResponsewithDeserializedBody in class HttpResponsedeserializedBody - the deserialized body/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/