#[non_exhaustive]pub struct ClientLeniency {
pub obs_fold_in_responses: bool,
}Expand description
Opt-in tolerances for responses a strict client would refuse. All are off by default; requests are never parsed leniently.
obs_fold_in_responses: replace each obsolete line fold in a response head (a field line continued on the next line, which begins with a space or tab) by overwriting the fold’s CR and LF with spaces, as RFC 9112 section 5.2 tells a user agent to do. The rewrite happens in place in the connection’s buffer, so offsets do not move, views stay borrowed, and nothing is allocated. Whitespace before the first field is still refused.
Bare LF, bare CR, Content-Length with Transfer-Encoding on a
response that has a body, and whitespace before a colon are never
tolerated: they are how messages get framed differently by different
hops. A response with no body (HEAD, 1xx, 204, 304, 2xx to CONNECT)
ends at its blank line whatever its framing fields say.
§Examples
use http_net::{ClientConn, ClientEvent, ClientLeniency, Request};
let mut conn = ClientConn::new();
conn.set_leniency(ClientLeniency::new().with_obs_fold_in_responses(true));
conn.send_request(&Request::get("/").header("host", "a"), &mut Vec::new())?;
let _ = conn.feed(b"HTTP/1.1 200 OK\r\nX-Long: part one,\r\n part two\r\nContent-Length: 0\r\n\r\n");
let ClientEvent::Response(resp) = conn.poll()? else { panic!() };
assert_eq!(resp.header("x-long"), Some(&b"part one, part two"[..]));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.obs_fold_in_responses: boolReplace obs-folds in response fields with spaces instead of refusing
them with HttpError::ObsFold.
Implementations§
Source§impl ClientLeniency
impl ClientLeniency
Sourcepub const fn new() -> Self
pub const fn new() -> Self
Every tolerance off (the strict default).
§Examples
assert!(!http_net::ClientLeniency::new().obs_fold_in_responses);Sourcepub const fn with_obs_fold_in_responses(self, on: bool) -> Self
pub const fn with_obs_fold_in_responses(self, on: bool) -> Self
Sets obs_fold_in_responses.
§Examples
let l = http_net::ClientLeniency::new().with_obs_fold_in_responses(true);
assert!(l.obs_fold_in_responses);Trait Implementations§
Source§impl Clone for ClientLeniency
impl Clone for ClientLeniency
impl Copy for ClientLeniency
Source§impl Debug for ClientLeniency
impl Debug for ClientLeniency
Source§impl Default for ClientLeniency
impl Default for ClientLeniency
impl Eq for ClientLeniency
Source§impl Hash for ClientLeniency
impl Hash for ClientLeniency
Source§impl PartialEq for ClientLeniency
impl PartialEq for ClientLeniency
impl StructuralPartialEq for ClientLeniency
Auto Trait Implementations§
impl Freeze for ClientLeniency
impl RefUnwindSafe for ClientLeniency
impl Send for ClientLeniency
impl Sync for ClientLeniency
impl Unpin for ClientLeniency
impl UnsafeUnpin for ClientLeniency
impl UnwindSafe for ClientLeniency
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