pub enum MockHttpResponse {
Success(Bytes),
Error(StatusCode, String),
ErrorResponse(StatusCode, Bytes),
ErrorWithHeaders(StatusCode, String, Box<HeaderMap>),
ErrorResponseWithHeaders(StatusCode, Bytes, Box<HeaderMap>),
}test-utils only.Expand description
Response scripted for RecordingHttpClient.
Variants§
Success(Bytes)
Return this body with a successful HTTP status.
Error(StatusCode, String)
Return a status-code error with the given body text.
ErrorResponse(StatusCode, Bytes)
Return an HTTP response with the given (typically non-success) status and body, instead of a transport-level error.
ErrorWithHeaders(StatusCode, String, Box<HeaderMap>)
Return a status-code error that preserved the failed response’s headers, exactly as the bundled reqwest transport does (rig#2210).
ErrorResponseWithHeaders(StatusCode, Bytes, Box<HeaderMap>)
Return an HTTP response with the given (typically non-success) status, body, and response headers, instead of a transport-level error.
Implementations§
Source§impl MockHttpResponse
impl MockHttpResponse
Sourcepub fn success(body: impl Into<Bytes>) -> MockHttpResponse
Available on crate features test-utils only.
pub fn success(body: impl Into<Bytes>) -> MockHttpResponse
test-utils only.Create a successful response from bytes.
Sourcepub fn error(status: StatusCode, message: impl Into<String>) -> MockHttpResponse
Available on crate features test-utils only.
pub fn error(status: StatusCode, message: impl Into<String>) -> MockHttpResponse
test-utils only.Create an error response with a status code and message.
Models a transport that reports a non-success status without
preserving the response headers (a custom HttpClientExt); use
Self::error_with_headers for the bundled reqwest behavior.
Sourcepub fn error_with_headers(
status: StatusCode,
message: impl Into<String>,
headers: HeaderMap,
) -> MockHttpResponse
Available on crate features test-utils only.
pub fn error_with_headers( status: StatusCode, message: impl Into<String>, headers: HeaderMap, ) -> MockHttpResponse
test-utils only.Create a transport-level status error that preserved the failed response’s headers, as the bundled reqwest transport does.
Trait Implementations§
Source§impl Clone for MockHttpResponse
impl Clone for MockHttpResponse
Source§fn clone(&self) -> MockHttpResponse
fn clone(&self) -> MockHttpResponse
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more