pub enum MockHttpResponse {
Success(Bytes),
SuccessWithHeaders(Bytes, HeaderMap),
ErrorResponse(StatusCode, Bytes),
ErrorWithHeaders(StatusCode, String, HeaderMap),
ErrorResponseWithHeaders(StatusCode, Bytes, HeaderMap),
}test-utils only.Expand description
Response scripted for RecordingHttpClient.
Variants§
Success(Bytes)
Return this body with a successful HTTP status and no headers.
SuccessWithHeaders(Bytes, HeaderMap)
Return this body with a successful HTTP status and these headers —
the reply whose Content-Type decides how it may be framed.
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, 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, 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_typed(body: impl Into<Bytes>, content_type: &'static str) -> Self
pub fn success_typed(body: impl Into<Bytes>, content_type: &'static str) -> Self
Create a successful response carrying content_type.
Sourcepub fn error(status: StatusCode, message: impl Into<String>) -> Self
pub fn error(status: StatusCode, message: impl Into<String>) -> Self
Create a transport-level status error whose reply carried no headers
of interest: the same shape as Self::error_with_headers with an
empty map, since a rejection always comes with its headers.
Sourcepub fn error_with_headers(
status: StatusCode,
message: impl Into<String>,
headers: HeaderMap,
) -> Self
pub fn error_with_headers( status: StatusCode, message: impl Into<String>, headers: HeaderMap, ) -> Self
Create a transport-level status error that preserved the failed response’s headers, as the bundled reqwest transport does.