public class MockHttpResponse extends HttpResponse
| Constructor and Description |
|---|
MockHttpResponse(HttpRequest request,
int statusCode)
Creates a HTTP response associated with a
request, returns the statusCode, and has an empty
response body. |
MockHttpResponse(HttpRequest request,
int statusCode,
byte[] bodyBytes)
Creates an HTTP response associated with a
request, returns the statusCode, and response body of
bodyBytes. |
MockHttpResponse(HttpRequest request,
int statusCode,
HttpHeaders headers) |
MockHttpResponse(HttpRequest request,
int statusCode,
HttpHeaders headers,
byte[] bodyBytes)
Creates an HTTP response associated with a
request, returns the statusCode, contains the
headers, and response body of bodyBytes. |
MockHttpResponse(HttpRequest request,
int statusCode,
HttpHeaders headers,
Object serializable)
Creates an HTTP response associated with a
request, returns the statusCode, contains the given
headers, and response body that is JSON serialized from serializable. |
MockHttpResponse(HttpRequest request,
int statusCode,
Object serializable) |
| Modifier and Type | Method and Description |
|---|---|
MockHttpResponse |
addHeader(String name,
String value)
Adds the header
name and value to the existing set of HTTP headers. |
Flux<ByteBuffer> |
getBody() |
Mono<byte[]> |
getBodyAsByteArray() |
Mono<String> |
getBodyAsString() |
Mono<String> |
getBodyAsString(Charset charset) |
HttpHeaders |
getHeaders() |
String |
getHeaderValue(String name) |
int |
getStatusCode() |
buffer, close, getRequestpublic MockHttpResponse(HttpRequest request, int statusCode)
request, returns the statusCode, and has an empty
response body.request - HttpRequest associated with the response.statusCode - Status code of the response.public MockHttpResponse(HttpRequest request, int statusCode, byte[] bodyBytes)
request, returns the statusCode, and response body of
bodyBytes.request - HttpRequest associated with the response.statusCode - Status code of the response.bodyBytes - Contents of the response.public MockHttpResponse(HttpRequest request, int statusCode, HttpHeaders headers)
public MockHttpResponse(HttpRequest request, int statusCode, HttpHeaders headers, byte[] bodyBytes)
request, returns the statusCode, contains the
headers, and response body of bodyBytes.request - HttpRequest associated with the response.statusCode - Status code of the response.headers - HttpHeaders of the response.bodyBytes - Contents of the response.public MockHttpResponse(HttpRequest request, int statusCode, HttpHeaders headers, Object serializable)
request, returns the statusCode, contains the given
headers, and response body that is JSON serialized from serializable.request - HttpRequest associated with the response.headers - HttpHeaders of the response.statusCode - Status code of the response.serializable - Contents to be serialized into JSON for the response.public MockHttpResponse(HttpRequest request, int statusCode, Object serializable)
public int getStatusCode()
getStatusCode in class HttpResponsepublic String getHeaderValue(String name)
getHeaderValue in class HttpResponsepublic HttpHeaders getHeaders()
getHeaders in class HttpResponsepublic Mono<byte[]> getBodyAsByteArray()
getBodyAsByteArray in class HttpResponsepublic Flux<ByteBuffer> getBody()
getBody in class HttpResponsepublic Mono<String> getBodyAsString()
getBodyAsString in class HttpResponsepublic Mono<String> getBodyAsString(Charset charset)
getBodyAsString in class HttpResponsepublic MockHttpResponse addHeader(String name, String value)
name and value to the existing set of HTTP headers.name - The header to addvalue - The header value.Copyright © 2019 Microsoft Corporation. All rights reserved.