Lines Matching +full:get +full:- +full:uri
16 //! .uri("https://www.rust-lang.org/")
17 //! .header("User-Agent", "my-awesome-agent/1.0");
25 //! # fn needs_awesome_header() -> bool {
29 //! fn send(req: Request<()>) -> Response<()> {
40 //! fn respond_to(req: Request<()>) -> http::Result<Response<()>> {
41 //! if req.uri() != "/awesome-url" {
62 use crate::{Extensions, Result, Uri};
79 /// .uri("https://www.rust-lang.org/")
80 /// .header("User-Agent", "my-awesome-agent/1.0");
88 /// # fn needs_awesome_header() -> bool {
92 /// fn send(req: Request<()>) -> Response<()> {
103 /// fn respond_to(req: Request<()>) -> http::Result<Response<()>> {
104 /// if req.uri() != "/awesome-url" {
127 /// fn deserialize<T>(req: Request<Vec<u8>>) -> serde_json::Result<Request<T>>
147 /// fn serialize<T>(req: Request<T>) -> serde_json::Result<Request<Vec<u8>>>
164 /// The HTTP request head consists of a method, uri, version, and a set of
170 /// The request's URI
171 pub uri: Uri, field
188 /// through a builder-like pattern.
195 /// Creates a new builder-style object to manufacture a `Request`
205 /// .method("GET")
206 /// .uri("https://www.rust-lang.org/")
207 /// .header("X-Custom-Foo", "Bar")
212 pub fn builder() -> Builder { in builder()
216 /// Creates a new `Builder` initialized with a GET method and the given URI.
226 /// let request = Request::get("https://www.rust-lang.org/")
230 pub fn get<T>(uri: T) -> Builder in get() method
232 Uri: TryFrom<T>, in get()
233 <Uri as TryFrom<T>>::Error: Into<crate::Error>, in get()
236 Builder::new().method(Method::GET).uri(uri) in get()
239 /// Creates a new `Builder` initialized with a PUT method and the given URI.
249 /// let request = Request::put("https://www.rust-lang.org/")
253 pub fn put<T>(uri: T) -> Builder in put()
255 Uri: TryFrom<T>, in put()
256 <Uri as TryFrom<T>>::Error: Into<crate::Error>, in put()
259 Builder::new().method(Method::PUT).uri(uri) in put()
262 /// Creates a new `Builder` initialized with a POST method and the given URI.
272 /// let request = Request::post("https://www.rust-lang.org/")
276 pub fn post<T>(uri: T) -> Builder in post()
278 Uri: TryFrom<T>, in post()
279 <Uri as TryFrom<T>>::Error: Into<crate::Error>, in post()
282 Builder::new().method(Method::POST).uri(uri) in post()
285 /// Creates a new `Builder` initialized with a DELETE method and the given URI.
295 /// let request = Request::delete("https://www.rust-lang.org/")
299 pub fn delete<T>(uri: T) -> Builder in delete()
301 Uri: TryFrom<T>, in delete()
302 <Uri as TryFrom<T>>::Error: Into<crate::Error>, in delete()
305 Builder::new().method(Method::DELETE).uri(uri) in delete()
308 /// Creates a new `Builder` initialized with an OPTIONS method and the given URI.
318 /// let request = Request::options("https://www.rust-lang.org/")
323 pub fn options<T>(uri: T) -> Builder in options()
325 Uri: TryFrom<T>, in options()
326 <Uri as TryFrom<T>>::Error: Into<crate::Error>, in options()
329 Builder::new().method(Method::OPTIONS).uri(uri) in options()
332 /// Creates a new `Builder` initialized with a HEAD method and the given URI.
342 /// let request = Request::head("https://www.rust-lang.org/")
346 pub fn head<T>(uri: T) -> Builder in head()
348 Uri: TryFrom<T>, in head()
349 <Uri as TryFrom<T>>::Error: Into<crate::Error>, in head()
352 Builder::new().method(Method::HEAD).uri(uri) in head()
355 /// Creates a new `Builder` initialized with a CONNECT method and the given URI.
365 /// let request = Request::connect("https://www.rust-lang.org/")
369 pub fn connect<T>(uri: T) -> Builder in connect()
371 Uri: TryFrom<T>, in connect()
372 <Uri as TryFrom<T>>::Error: Into<crate::Error>, in connect()
375 Builder::new().method(Method::CONNECT).uri(uri) in connect()
378 /// Creates a new `Builder` initialized with a PATCH method and the given URI.
388 /// let request = Request::patch("https://www.rust-lang.org/")
392 pub fn patch<T>(uri: T) -> Builder in patch()
394 Uri: TryFrom<T>, in patch()
395 <Uri as TryFrom<T>>::Error: Into<crate::Error>, in patch()
397 Builder::new().method(Method::PATCH).uri(uri) in patch()
400 /// Creates a new `Builder` initialized with a TRACE method and the given URI.
410 /// let request = Request::trace("https://www.rust-lang.org/")
414 pub fn trace<T>(uri: T) -> Builder in trace()
416 Uri: TryFrom<T>, in trace()
417 <Uri as TryFrom<T>>::Error: Into<crate::Error>, in trace()
419 Builder::new().method(Method::TRACE).uri(uri) in trace()
427 /// the GET method, no headers, etc.
435 /// assert_eq!(*request.method(), Method::GET);
439 pub fn new(body: T) -> Request<T> { in new()
459 pub fn from_parts(parts: Parts, body: T) -> Request<T> { in from_parts()
473 /// assert_eq!(*request.method(), Method::GET);
476 pub fn method(&self) -> &Method { in method()
491 pub fn method_mut(&mut self) -> &mut Method { in method_mut()
495 /// Returns a reference to the associated URI.
502 /// assert_eq!(*request.uri(), *"/");
505 pub fn uri(&self) -> &Uri { in uri() method
506 &self.head.uri in uri()
509 /// Returns a mutable reference to the associated URI.
517 /// assert_eq!(*request.uri(), *"/hello");
520 pub fn uri_mut(&mut self) -> &mut Uri { in uri_mut() argument
521 &mut self.head.uri in uri_mut()
534 pub fn version(&self) -> Version { in version()
549 pub fn version_mut(&mut self) -> &mut Version { in version_mut()
563 pub fn headers(&self) -> &HeaderMap<HeaderValue> { in headers()
579 pub fn headers_mut(&mut self) -> &mut HeaderMap<HeaderValue> { in headers_mut()
590 /// assert!(request.extensions().get::<i32>().is_none());
593 pub fn extensions(&self) -> &Extensions { in extensions()
606 /// assert_eq!(request.extensions().get(), Some(&"hello"));
609 pub fn extensions_mut(&mut self) -> &mut Extensions { in extensions_mut()
623 pub fn body(&self) -> &T { in body()
638 pub fn body_mut(&mut self) -> &mut T { in body_mut()
653 pub fn into_body(self) -> T { in into_body()
665 /// assert_eq!(parts.method, Method::GET);
668 pub fn into_parts(self) -> (Parts, T) { in into_parts()
687 pub fn map<F, U>(self, f: F) -> Request<U> in map()
689 F: FnOnce(T) -> U, in map()
699 fn default() -> Request<T> { in default()
705 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { in fmt()
708 .field("uri", self.uri()) in fmt()
719 fn new() -> Parts { in new()
722 uri: Uri::default(), in new()
732 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { in fmt()
735 .field("uri", &self.uri) in fmt()
758 pub fn new() -> Builder { in new()
767 /// By default this is `GET`.
779 pub fn method<T>(self, method: T) -> Builder in method()
791 /// Get the HTTP Method for this request.
793 /// By default this is `GET`. If builder has error, returns None.
801 /// assert_eq!(req.method_ref(),Some(&Method::GET));
806 pub fn method_ref(&self) -> Option<&Method> { in method_ref()
810 /// Set the URI for this request.
812 /// This function will configure the URI of the `Request` that will
823 /// .uri("https://www.rust-lang.org/")
827 pub fn uri<T>(self, uri: T) -> Builder in uri() method
829 Uri: TryFrom<T>, in uri()
830 <Uri as TryFrom<T>>::Error: Into<crate::Error>, in uri()
833 head.uri = TryFrom::try_from(uri).map_err(Into::into)?; in uri()
838 /// Get the URI for this request
850 /// req = req.uri("https://www.rust-lang.org/");
851 /// assert_eq!(req.uri_ref().unwrap(), "https://www.rust-lang.org/" );
853 pub fn uri_ref(&self) -> Option<&Uri> { in uri_ref() argument
854 self.inner.as_ref().ok().map(|h| &h.uri) in uri_ref()
874 pub fn version(self, version: Version) -> Builder { in version()
881 /// Get the HTTP version for this request
896 pub fn version_ref(&self) -> Option<&Version> { in version_ref()
914 /// .header("X-Custom-Foo", "bar")
918 pub fn header<K, V>(self, key: K, value: V) -> Builder in header()
933 /// Get header on this request builder.
942 /// .header("X-Custom-Foo", "bar");
945 /// assert_eq!( headers["X-Custom-Foo"], "bar" );
947 pub fn headers_ref(&self) -> Option<&HeaderMap<HeaderValue>> { in headers_ref()
951 /// Get headers on this request builder.
963 /// headers.insert("X-Custom-Foo", HeaderValue::from_static("bar"));
967 /// assert_eq!( headers["X-Custom-Foo"], "bar" );
969 pub fn headers_mut(&mut self) -> Option<&mut HeaderMap<HeaderValue>> { in headers_mut()
985 /// assert_eq!(req.extensions().get::<&'static str>(),
988 pub fn extension<T>(self, extension: T) -> Builder in extension()
998 /// Get a reference to the extensions for this request builder.
1008 /// assert_eq!(extensions.get::<&'static str>(), Some(&"My Extension"));
1009 /// assert_eq!(extensions.get::<u32>(), Some(&5u32));
1011 pub fn extensions_ref(&self) -> Option<&Extensions> { in extensions_ref()
1015 /// Get a mutable reference to the extensions for this request builder.
1025 /// assert_eq!(extensions.get::<&'static str>(), Some(&"My Extension"));
1027 /// assert_eq!(extensions.get::<u32>(), Some(&5u32));
1029 pub fn extensions_mut(&mut self) -> Option<&mut Extensions> { in extensions_mut()
1039 /// failed to parse or get converted to the internal representation. For
1053 pub fn body<T>(self, body: T) -> Result<Request<T>> { in body()
1064 fn and_then<F>(self, func: F) -> Self in and_then()
1066 F: FnOnce(Parts) -> Result<Parts> in and_then()
1076 fn default() -> Builder { in default()