mirror of https://github.com/http-rs/http-types
commit
0127e5bdfd
|
@ -53,6 +53,7 @@ impl FromStr for AuthenticationScheme {
|
|||
// NOTE(yosh): matching here is lowercase as specified by RFC2617#section-1.2
|
||||
// > [...] case-insensitive token to identify the authentication scheme [...]
|
||||
// https://tools.ietf.org/html/rfc2617#section-1.2
|
||||
#[allow(clippy::match_str_case_mismatch)]
|
||||
match s.to_lowercase().as_str() {
|
||||
"basic" => Ok(Self::Basic),
|
||||
"bearer" => Ok(Self::Bearer),
|
||||
|
|
10
src/body.rs
10
src/body.rs
|
@ -565,13 +565,13 @@ impl<'a> From<&'a [u8]> for Body {
|
|||
}
|
||||
|
||||
impl AsyncRead for Body {
|
||||
#[allow(missing_doc_code_examples)]
|
||||
#[allow(rustdoc::missing_doc_code_examples)]
|
||||
fn poll_read(
|
||||
mut self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
buf: &mut [u8],
|
||||
) -> Poll<io::Result<usize>> {
|
||||
let mut buf = match self.length {
|
||||
let buf = match self.length {
|
||||
None => buf,
|
||||
Some(length) if length == self.bytes_read => return Poll::Ready(Ok(0)),
|
||||
Some(length) => {
|
||||
|
@ -582,14 +582,14 @@ impl AsyncRead for Body {
|
|||
}
|
||||
};
|
||||
|
||||
let bytes = ready!(Pin::new(&mut self.reader).poll_read(cx, &mut buf))?;
|
||||
let bytes = ready!(Pin::new(&mut self.reader).poll_read(cx, buf))?;
|
||||
self.bytes_read += bytes as u64;
|
||||
Poll::Ready(Ok(bytes))
|
||||
}
|
||||
}
|
||||
|
||||
impl AsyncBufRead for Body {
|
||||
#[allow(missing_doc_code_examples)]
|
||||
#[allow(rustdoc::missing_doc_code_examples)]
|
||||
fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<&'_ [u8]>> {
|
||||
self.project().reader.poll_fill_buf(cx)
|
||||
}
|
||||
|
@ -632,6 +632,7 @@ mod test {
|
|||
#[derive(Debug, Deserialize)]
|
||||
#[serde(crate = "serde_crate")]
|
||||
struct Foo {
|
||||
#[allow(dead_code)]
|
||||
inner: String,
|
||||
}
|
||||
let body = Body::empty();
|
||||
|
@ -644,6 +645,7 @@ mod test {
|
|||
#[derive(Debug, Deserialize)]
|
||||
#[serde(crate = "serde_crate")]
|
||||
struct Foo {
|
||||
#[allow(dead_code)]
|
||||
inner: String,
|
||||
}
|
||||
let body = Body::empty();
|
||||
|
|
|
@ -88,7 +88,7 @@ impl CacheDirective {
|
|||
return Ok(None);
|
||||
}
|
||||
|
||||
s.to_lowercase();
|
||||
let s = s.to_lowercase();
|
||||
let mut parts = s.split('=');
|
||||
let next = parts.next().unwrap();
|
||||
|
||||
|
|
|
@ -220,8 +220,8 @@ impl Header for ClearSiteData {
|
|||
let mut output = String::new();
|
||||
for (n, etag) in self.entries.iter().enumerate() {
|
||||
match n {
|
||||
0 => write!(output, "{}", etag.to_string()).unwrap(),
|
||||
_ => write!(output, ", {}", etag.to_string()).unwrap(),
|
||||
0 => write!(output, "{}", etag).unwrap(),
|
||||
_ => write!(output, ", {}", etag).unwrap(),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -111,8 +111,8 @@ impl Header for IfMatch {
|
|||
let mut output = String::new();
|
||||
for (n, etag) in self.entries.iter().enumerate() {
|
||||
match n {
|
||||
0 => write!(output, "{}", etag.to_string()).unwrap(),
|
||||
_ => write!(output, ", {}", etag.to_string()).unwrap(),
|
||||
0 => write!(output, "{}", etag).unwrap(),
|
||||
_ => write!(output, ", {}", etag).unwrap(),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -117,8 +117,8 @@ impl Header for IfNoneMatch {
|
|||
let mut output = String::new();
|
||||
for (n, etag) in self.entries.iter().enumerate() {
|
||||
match n {
|
||||
0 => write!(output, "{}", etag.to_string()).unwrap(),
|
||||
_ => write!(output, ", {}", etag.to_string()).unwrap(),
|
||||
0 => write!(output, "{}", etag).unwrap(),
|
||||
_ => write!(output, ", {}", etag).unwrap(),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ impl Error {
|
|||
|
||||
/// Retrieves a reference to the type name of the error, if available.
|
||||
pub fn type_name(&self) -> Option<&str> {
|
||||
self.type_name.as_deref()
|
||||
self.type_name
|
||||
}
|
||||
|
||||
/// Converts anything which implements `Display` into an `http_types::Error`.
|
||||
|
|
|
@ -68,7 +68,7 @@ impl TryFrom<HeaderName> for http::header::HeaderName {
|
|||
|
||||
fn try_from(name: HeaderName) -> Result<Self, Self::Error> {
|
||||
let name = name.as_str().as_bytes();
|
||||
http::header::HeaderName::from_bytes(name).map_err(|e| Error::new_adhoc(e))
|
||||
http::header::HeaderName::from_bytes(name).map_err(Error::new_adhoc)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ impl TryFrom<HeaderValue> for http::header::HeaderValue {
|
|||
|
||||
fn try_from(value: HeaderValue) -> Result<Self, Self::Error> {
|
||||
let value = value.as_str().as_bytes();
|
||||
http::header::HeaderValue::from_bytes(value).map_err(|e| Error::new_adhoc(e))
|
||||
http::header::HeaderValue::from_bytes(value).map_err(Error::new_adhoc)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -413,6 +413,7 @@ impl FromStr for Method {
|
|||
type Err = crate::Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
#[allow(clippy::match_str_case_mismatch)]
|
||||
match &*s.to_ascii_uppercase() {
|
||||
"ACL" => Ok(Self::Acl),
|
||||
"BASELINE-CONTROL" => Ok(Self::BaselineControl),
|
||||
|
|
|
@ -899,7 +899,7 @@ impl Clone for Request {
|
|||
}
|
||||
|
||||
impl AsyncRead for Request {
|
||||
#[allow(missing_doc_code_examples)]
|
||||
#[allow(rustdoc::missing_doc_code_examples)]
|
||||
fn poll_read(
|
||||
mut self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
|
@ -910,7 +910,7 @@ impl AsyncRead for Request {
|
|||
}
|
||||
|
||||
impl AsyncBufRead for Request {
|
||||
#[allow(missing_doc_code_examples)]
|
||||
#[allow(rustdoc::missing_doc_code_examples)]
|
||||
fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<&'_ [u8]>> {
|
||||
let this = self.project();
|
||||
this.body.poll_fill_buf(cx)
|
||||
|
|
|
@ -599,7 +599,7 @@ impl Clone for Response {
|
|||
}
|
||||
|
||||
impl AsyncRead for Response {
|
||||
#[allow(missing_doc_code_examples)]
|
||||
#[allow(rustdoc::missing_doc_code_examples)]
|
||||
fn poll_read(
|
||||
mut self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
|
@ -610,7 +610,7 @@ impl AsyncRead for Response {
|
|||
}
|
||||
|
||||
impl AsyncBufRead for Response {
|
||||
#[allow(missing_doc_code_examples)]
|
||||
#[allow(rustdoc::missing_doc_code_examples)]
|
||||
fn poll_fill_buf(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<&'_ [u8]>> {
|
||||
let this = self.project();
|
||||
this.body.poll_fill_buf(cx)
|
||||
|
|
|
@ -218,10 +218,10 @@ impl From<SystemTime> for HttpDate {
|
|||
.expect("all times should be after the epoch");
|
||||
let secs_since_epoch = dur.as_secs();
|
||||
|
||||
if secs_since_epoch >= YEAR_9999_SECONDS {
|
||||
// year 9999
|
||||
panic!("date must be before year 9999");
|
||||
}
|
||||
assert!(
|
||||
secs_since_epoch < YEAR_9999_SECONDS,
|
||||
"date must be before year 9999"
|
||||
);
|
||||
|
||||
/* 2000-03-01 (mod 400 year, immediately after feb29 */
|
||||
const LEAPOCH: i64 = 11017;
|
||||
|
|
Loading…
Reference in New Issue