public abstract class HttpResponse extends Object implements Closeable
HttpRequest.| Constructor and Description |
|---|
HttpResponse() |
| Modifier and Type | Method and Description |
|---|---|
abstract reactor.core.publisher.Flux<io.netty.buffer.ByteBuf> |
body()
Get the publisher emitting response content chunks.
|
abstract reactor.core.publisher.Mono<byte[]> |
bodyAsByteArray()
Get the response content as a byte[].
|
abstract reactor.core.publisher.Mono<String> |
bodyAsString()
Get the response content as a string.
|
abstract reactor.core.publisher.Mono<String> |
bodyAsString(Charset charset)
Get the response content as a string.
|
HttpResponse |
buffer()
Get a new Response object wrapping this response with it's content
buffered into memory.
|
void |
close()
Closes the response content stream, if any.
|
abstract HttpHeaders |
headers()
Get all response headers.
|
abstract String |
headerValue(String name)
Lookup a response header with the provided name.
|
HttpRequest |
request()
Get the request which resulted in this response.
|
HttpResponse |
request(HttpRequest request)
Sets the request which resulted in this HttpResponse.
|
abstract int |
statusCode()
Get the response status code.
|
public abstract int statusCode()
public abstract String headerValue(String name)
name - the name of the header to lookup.public abstract HttpHeaders headers()
public abstract reactor.core.publisher.Flux<io.netty.buffer.ByteBuf> 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.
ByteBuf.public abstract reactor.core.publisher.Mono<byte[]> bodyAsByteArray()
public abstract reactor.core.publisher.Mono<String> bodyAsString()
public abstract reactor.core.publisher.Mono<String> bodyAsString(Charset charset)
charset - the charset to use as encodingpublic final HttpRequest request()
public final HttpResponse request(HttpRequest request)
request - the requestpublic HttpResponse buffer()
public void close()
close in interface Closeableclose in interface AutoCloseableCopyright © 2019 Microsoft Corporation. All rights reserved.