@@ -12,7 +12,6 @@ use crate::headers::{
12
12
} ;
13
13
use crate :: mime:: Mime ;
14
14
use crate :: trailers:: { self , Trailers } ;
15
- use crate :: Cookie ;
16
15
use crate :: { Body , Method , TypeMap , Url , Version } ;
17
16
18
17
pin_project_lite:: pin_project! {
@@ -363,74 +362,6 @@ impl Request {
363
362
self . version = version;
364
363
}
365
364
366
- /// Get all cookies.
367
- ///
368
- /// # Examples
369
- ///
370
- /// ```
371
- /// # fn main() -> Result<(), http_types::Error> {
372
- /// #
373
- /// use http_types::{Cookie, Url, Method, Request, Version};
374
- ///
375
- /// let mut req = Request::new(Method::Get, Url::parse("https://example.com")?);
376
- /// req.set_cookie(Cookie::new("name", "value"));
377
- /// assert_eq!(req.cookies().unwrap(), vec![Cookie::new("name", "value")]);
378
- /// #
379
- /// # Ok(()) }
380
- /// ```
381
- pub fn cookies ( & self ) -> Result < Vec < Cookie < ' _ > > , crate :: Error > {
382
- match self . header ( & headers:: COOKIE ) {
383
- None => Ok ( vec ! [ ] ) ,
384
- Some ( h) => h. iter ( ) . try_fold ( vec ! [ ] , |mut acc, h| {
385
- let cookie = Cookie :: parse ( h. as_str ( ) ) ?;
386
- acc. push ( cookie) ;
387
- Ok ( acc)
388
- } ) ,
389
- }
390
- }
391
-
392
- /// Get a cookie by name.
393
- ///
394
- /// # Examples
395
- ///
396
- /// ```
397
- /// # fn main() -> Result<(), http_types::Error> {
398
- /// #
399
- /// use http_types::{Cookie, Url, Method, Request, Version};
400
- ///
401
- /// let mut req = Request::new(Method::Get, Url::parse("https://example.com")?);
402
- /// req.set_cookie(Cookie::new("name", "value"));
403
- /// assert_eq!(req.cookie("name").unwrap(), Some(Cookie::new("name", "value")));
404
- /// #
405
- /// # Ok(()) }
406
- /// ```
407
- pub fn cookie ( & self , name : & str ) -> Result < Option < Cookie < ' _ > > , crate :: Error > {
408
- let cookies = self . cookies ( ) ?;
409
- let cookie = cookies. into_iter ( ) . find ( |c| c. name ( ) == name) ;
410
- Ok ( cookie)
411
- }
412
-
413
- /// Set a cookie.
414
- ///
415
- /// This will not override any existing cookies, and uses the `Cookies` header.
416
- ///
417
- /// # Examples
418
- ///
419
- /// ```
420
- /// # fn main() -> Result<(), http_types::Error> {
421
- /// #
422
- /// use http_types::{Cookie, Url, Method, Request, Version};
423
- ///
424
- /// let mut req = Request::new(Method::Get, Url::parse("https://example.com")?);
425
- /// req.set_cookie(Cookie::new("name", "value"));
426
- /// #
427
- /// # Ok(()) }
428
- /// ```
429
- pub fn set_cookie ( & mut self , cookie : Cookie < ' _ > ) {
430
- self . append_header ( headers:: COOKIE , HeaderValue :: from ( cookie) )
431
- . unwrap ( ) ;
432
- }
433
-
434
365
/// Sends trailers to the a receiver.
435
366
pub fn send_trailers ( & mut self ) -> trailers:: Sender {
436
367
let sender = self
0 commit comments