web_faith/request.rs
1//! Requests and their builders.
2
3// spec:REQ spec:ENC spec:CANCEL
4
5mod builder;
6mod parts;
7mod send;
8mod target;
9
10pub use builder::{FetchBuilder, Priority, Request, RequestBuilder};
11pub use target::Target;
12
13// Compiled and used internally either way; `unstable-internals` decides whether they are nameable
14// outside.
15#[cfg(not(feature = "unstable-internals"))]
16pub(crate) use parts::{RequestBody, RequestOptions};
17#[cfg(feature = "unstable-internals")]
18pub use {
19 parts::{RequestBody, RequestOptions},
20 send::send,
21};
22
23/// Whether a request carries its credentials.
24#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
25pub enum Credentials {
26 /// Strip credentials from the URL and send no cookies.
27 Omit,
28 /// Send them. Almost always what a server-side caller means.
29 #[default]
30 Include,
31}
32
33/// The methods the fetch standard normalises to upper case; any other method is sent as given.
34// spec:REQ#method-and-headers
35const NORMALISED_METHODS: [&str; 6] = ["DELETE", "GET", "HEAD", "OPTIONS", "POST", "PUT"];
36
37/// The method whose query content rides in the body, and so must be described by a `Content-Type`.
38///
39/// `http` has no constant for it: `QUERY` is still a draft method, so it arrives as an extension
40/// method and is compared by name.
41// spec:REQ#body
42pub(crate) const QUERY: &str = "QUERY";
43
44/// The header a request's priority is expressed in.
45// spec:REQ#request-priority
46pub(crate) const PRIORITY: &str = "priority";