pub struct UpgradeResponse { /* private fields */ }
Expand description
The server’s response to the WebSocket
upgrade request.
On non-wasm platforms, this implements Deref<Target = Response>
, so you
can access all the usual information from the reqwest::Response
.
Implementations§
Source§impl UpgradeResponse
impl UpgradeResponse
Sourcepub async fn into_websocket(self) -> Result<WebSocket, Error>
pub async fn into_websocket(self) -> Result<WebSocket, Error>
Turns the response into a WebSocket
.
This checks if the WebSocket
handshake was successful.
Sourcepub fn into_inner(self) -> Response
pub fn into_inner(self) -> Response
Consumes the response and returns the inner reqwest::Response
.
Methods from Deref<Target = Response>§
Sourcepub fn status(&self) -> StatusCode
pub fn status(&self) -> StatusCode
Get the StatusCode
of this Response
.
Sourcepub fn content_length(&self) -> Option<u64>
pub fn content_length(&self) -> Option<u64>
Get the content-length of this response, if known.
Reasons it may not be known:
- The server didn’t send a
content-length
header. - The response is compressed and automatically decoded (thus changing the actual decoded length).
Sourcepub fn remote_addr(&self) -> Option<SocketAddr>
pub fn remote_addr(&self) -> Option<SocketAddr>
Get the remote address used to get this Response
.
Sourcepub fn extensions(&self) -> &Extensions
pub fn extensions(&self) -> &Extensions
Returns a reference to the associated extensions.
Sourcepub fn error_for_status_ref(&self) -> Result<&Response, Error>
pub fn error_for_status_ref(&self) -> Result<&Response, Error>
Turn a reference to a response into an error if the server returned an error.
§Example
fn on_response(res: &Response) {
match res.error_for_status_ref() {
Ok(_res) => (),
Err(err) => {
// asserting a 400 as an example
// it could be any status between 400...599
assert_eq!(
err.status(),
Some(reqwest::StatusCode::BAD_REQUEST)
);
}
}
}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for UpgradeResponse
impl !RefUnwindSafe for UpgradeResponse
impl Send for UpgradeResponse
impl Sync for UpgradeResponse
impl Unpin for UpgradeResponse
impl !UnwindSafe for UpgradeResponse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more