Skip to content

Commit

Permalink
feat: provide access to cookies on response
Browse files Browse the repository at this point in the history
Resolved dead_code warning and was useful even if not to me
  • Loading branch information
c-git committed Aug 20, 2024
1 parent b8dc3ed commit 509630a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/wasm/response.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use std::fmt;

#[cfg(feature = "cookies")]
use crate::cookie;
use bytes::Bytes;
use http::{HeaderMap, StatusCode};
use js_sys::Uint8Array;
Expand Down Expand Up @@ -72,6 +74,19 @@ impl Response {
.ok()
}

/// Retrieve the cookies contained in the response.
///
/// Note that invalid 'Set-Cookie' headers will be ignored.
///
/// # Optional
///
/// This requires the optional `cookies` feature to be enabled.
#[cfg(feature = "cookies")]
#[cfg_attr(docsrs, doc(cfg(feature = "cookies")))]
pub fn cookies<'a>(&'a self) -> impl Iterator<Item = cookie::Cookie<'a>> + 'a {
cookie::extract_response_cookies(self.http.headers()).filter_map(Result::ok)
}

/// Get the final `Url` of this `Response`.
#[inline]
pub fn url(&self) -> &Url {
Expand Down

0 comments on commit 509630a

Please sign in to comment.