Skip to content

Updated dependencies #521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 38 additions & 21 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -6,7 +6,13 @@ repository = "https://github.com/http-rs/http-types"
documentation = "https://docs.rs/http-types"
description = "Common types for HTTP operations."
keywords = ["http", "types", "request", "response", "h2"]
categories = ["asynchronous", "web-programming", "web-programming::http-client", "web-programming::http-server", "web-programming::websocket"]
categories = [
"asynchronous",
"web-programming",
"web-programming::http-client",
"web-programming::http-server",
"web-programming::websocket",
]
authors = ["Yoshua Wuyts <yoshuawuyts@gmail.com>"]
readme = "README.md"
edition = "2018"
@@ -19,39 +25,50 @@ rustdoc-args = ["--cfg", "feature=\"docs\""]
default = ["fs", "cookie-secure", "serde"]
docs = ["unstable"]
unstable = []
hyperium_http = ["http"]
hyperium_http = ["hyperium_http_02"]
hyperium_http_02 = ["http02"]
hyperium_http_1 = ["http1"]
async_std = ["fs"]
cookies = ["cookie"]
cookie-secure = ["cookies", "cookie/secure"]
fs = ["async-std"]
serde = ["serde_qs", "serde_crate", "serde_json", "serde_urlencoded", "url/serde"]
serde = [
"serde_qs",
"serde_crate",
"serde_json",
"serde_urlencoded",
"url/serde",
]

[dependencies]
fastrand = "1.4.0"
base64 = "0.13.0"
futures-lite = "1.11.1"
async-channel = "1.5.1"
infer = "0.7.0"
pin-project-lite = "0.2.0"
url = "2.1.1"
anyhow = "1.0.26"
fastrand = "2.0.1"
base64 = "0.21.5"
futures-lite = "2.2.0"
async-channel = "2.1.1"
infer = "0.15.0"
pin-project-lite = "0.2.13"
url = "2.5.0"
anyhow = "1.0.79"

# features: async_std
async-std = { version = "1.6.0", optional = true }
async-std = { version = "1.12.0", optional = true }

# features: hyperium/http
http = { version = "0.2.0", optional = true }
# features: hyperium_http or hyperium_http_02
http02 = { package = "http", version = "0.2.0", optional = true }
# features: hyperium_http_1
http1 = { package = "http", version = "1.0.0", optional = true }

# features: cookies
cookie = { version = "0.16.0", features = ["percent-encode"], optional = true }
cookie = { version = "0.18.0", features = ["percent-encode"], optional = true }

# features: serde
serde_json = { version = "1.0.51", optional = true }
serde_crate = { version = "1.0.106", features = ["derive"], optional = true, package = "serde" }
serde_urlencoded = { version = "0.7.0", optional = true}
serde_qs = { version = "0.9.1", optional = true }
serde_json = { version = "1.0.111", optional = true }
serde_crate = { version = "1.0.195", features = [
"derive",
], optional = true, package = "serde" }
serde_urlencoded = { version = "0.7.1", optional = true }
serde_qs = { version = "0.12.0", optional = true }


[dev-dependencies]
http = "0.2.0"
async-std = { version = "1.6.0", features = ["attributes"] }
async-std = { version = "1.12.0", features = ["attributes"] }
2 changes: 2 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[toolchain]
channel = "nightly"
14 changes: 12 additions & 2 deletions src/auth/basic_auth.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use base64::Engine;

use crate::headers::{HeaderName, HeaderValue, Headers, AUTHORIZATION};
use crate::Status;
use crate::{
@@ -71,7 +73,9 @@ impl BasicAuth {

/// Create a new instance from the base64 encoded credentials.
pub fn from_credentials(credentials: impl AsRef<[u8]>) -> crate::Result<Self> {
let bytes = base64::decode(credentials).status(400)?;
let bytes = base64::engine::general_purpose::STANDARD
.decode(credentials)
.status(400)?;
let credentials = String::from_utf8(bytes).status(400)?;

let mut iter = credentials.splitn(2, ':');
@@ -105,7 +109,13 @@ impl Header for BasicAuth {

fn header_value(&self) -> HeaderValue {
let scheme = AuthenticationScheme::Basic;
let credentials = base64::encode(format!("{}:{}", self.username, self.password));

let mut credentials = String::new();
base64::engine::general_purpose::STANDARD.encode_string(
format!("{}:{}", self.username, self.password),
&mut credentials,
);

let auth = Authorization::new(scheme, credentials);
auth.header_value()
}
102 changes: 51 additions & 51 deletions src/hyperium_http.rs
Original file line number Diff line number Diff line change
@@ -5,95 +5,95 @@ use crate::{Body, Error, Method, Request, Response, StatusCode, Url, Version};
use std::convert::{TryFrom, TryInto};
use std::str::FromStr;

impl From<http::Method> for Method {
fn from(method: http::Method) -> Self {
impl From<http02::Method> for Method {
fn from(method: http02::Method) -> Self {
Method::from_str(method.as_str()).unwrap()
}
}

impl From<Method> for http::Method {
impl From<Method> for http02::Method {
fn from(method: Method) -> Self {
http::Method::from_str(method.as_ref()).unwrap()
http02::Method::from_str(method.as_ref()).unwrap()
}
}

impl From<http::StatusCode> for StatusCode {
fn from(status: http::StatusCode) -> Self {
impl From<http02::StatusCode> for StatusCode {
fn from(status: http02::StatusCode) -> Self {
StatusCode::try_from(status.as_u16()).unwrap()
}
}

impl From<StatusCode> for http::StatusCode {
impl From<StatusCode> for http02::StatusCode {
fn from(status: StatusCode) -> Self {
http::StatusCode::from_u16(status.into()).unwrap()
http02::StatusCode::from_u16(status.into()).unwrap()
}
}

impl From<http::Version> for Version {
fn from(version: http::Version) -> Self {
impl From<http02::Version> for Version {
fn from(version: http02::Version) -> Self {
match version {
http::Version::HTTP_09 => Version::Http0_9,
http::Version::HTTP_10 => Version::Http1_0,
http::Version::HTTP_11 => Version::Http1_1,
http::Version::HTTP_2 => Version::Http2_0,
http::Version::HTTP_3 => Version::Http3_0,
http02::Version::HTTP_09 => Version::Http0_9,
http02::Version::HTTP_10 => Version::Http1_0,
http02::Version::HTTP_11 => Version::Http1_1,
http02::Version::HTTP_2 => Version::Http2_0,
http02::Version::HTTP_3 => Version::Http3_0,
_ => panic!("unknown HTTP version conversion"),
}
}
}

impl From<Version> for http::Version {
impl From<Version> for http02::Version {
fn from(version: Version) -> Self {
match version {
Version::Http0_9 => http::Version::HTTP_09,
Version::Http1_0 => http::Version::HTTP_10,
Version::Http1_1 => http::Version::HTTP_11,
Version::Http2_0 => http::Version::HTTP_2,
Version::Http3_0 => http::Version::HTTP_3,
Version::Http0_9 => http02::Version::HTTP_09,
Version::Http1_0 => http02::Version::HTTP_10,
Version::Http1_1 => http02::Version::HTTP_11,
Version::Http2_0 => http02::Version::HTTP_2,
Version::Http3_0 => http02::Version::HTTP_3,
}
}
}

impl TryFrom<http::header::HeaderName> for HeaderName {
impl TryFrom<http02::header::HeaderName> for HeaderName {
type Error = Error;

fn try_from(name: http::header::HeaderName) -> Result<Self, Self::Error> {
fn try_from(name: http02::header::HeaderName) -> Result<Self, Self::Error> {
let name = name.as_str().as_bytes().to_owned();
HeaderName::from_bytes(name)
}
}

impl TryFrom<HeaderName> for http::header::HeaderName {
impl TryFrom<HeaderName> for http02::header::HeaderName {
type Error = Error;

fn try_from(name: HeaderName) -> Result<Self, Self::Error> {
let name = name.as_str().as_bytes();
http::header::HeaderName::from_bytes(name).map_err(Error::new_adhoc)
http02::header::HeaderName::from_bytes(name).map_err(Error::new_adhoc)
}
}

impl TryFrom<http::header::HeaderValue> for HeaderValue {
impl TryFrom<http02::header::HeaderValue> for HeaderValue {
type Error = Error;

fn try_from(value: http::header::HeaderValue) -> Result<Self, Self::Error> {
fn try_from(value: http02::header::HeaderValue) -> Result<Self, Self::Error> {
let value = value.as_bytes().to_owned();
HeaderValue::from_bytes(value)
}
}

impl TryFrom<HeaderValue> for http::header::HeaderValue {
impl TryFrom<HeaderValue> for http02::header::HeaderValue {
type Error = Error;

fn try_from(value: HeaderValue) -> Result<Self, Self::Error> {
let value = value.as_str().as_bytes();
http::header::HeaderValue::from_bytes(value).map_err(Error::new_adhoc)
http02::header::HeaderValue::from_bytes(value).map_err(Error::new_adhoc)
}
}

impl TryFrom<http::HeaderMap> for Headers {
impl TryFrom<http02::HeaderMap> for Headers {
type Error = Error;

fn try_from(hyperium_headers: http::HeaderMap) -> Result<Self, Self::Error> {
fn try_from(hyperium_headers: http02::HeaderMap) -> Result<Self, Self::Error> {
let mut headers = Headers::new();

hyperium_headers
@@ -112,21 +112,21 @@ impl TryFrom<http::HeaderMap> for Headers {
}
}

impl TryFrom<Headers> for http::HeaderMap {
impl TryFrom<Headers> for http02::HeaderMap {
type Error = Error;

fn try_from(headers: Headers) -> Result<Self, Self::Error> {
let mut hyperium_headers = http::HeaderMap::new();
let mut hyperium_headers = http02::HeaderMap::new();

headers
.into_iter()
.map(|(name, values)| {
let name: http::header::HeaderName = name.try_into()?;
let name: http02::header::HeaderName = name.try_into()?;

values
.into_iter()
.map(|value| {
let value: http::header::HeaderValue = value.try_into()?;
let value: http02::header::HeaderValue = value.try_into()?;
hyperium_headers.append(&name, value);
Ok(())
})
@@ -141,7 +141,7 @@ impl TryFrom<Headers> for http::HeaderMap {
}

fn hyperium_headers_to_headers(
hyperium_headers: http::HeaderMap,
hyperium_headers: http02::HeaderMap,
headers: &mut Headers,
) -> crate::Result<()> {
for (name, value) in hyperium_headers {
@@ -156,33 +156,33 @@ fn hyperium_headers_to_headers(
Ok(())
}

fn headers_to_hyperium_headers(headers: &mut Headers, hyperium_headers: &mut http::HeaderMap) {
fn headers_to_hyperium_headers(headers: &mut Headers, hyperium_headers: &mut http02::HeaderMap) {
for (name, values) in headers {
let name = format!("{}", name).into_bytes();
let name = http::header::HeaderName::from_bytes(&name).unwrap();
let name = http02::header::HeaderName::from_bytes(&name).unwrap();

for value in values.iter() {
let value = format!("{}", value).into_bytes();
let value = http::header::HeaderValue::from_bytes(&value).unwrap();
let value = http02::header::HeaderValue::from_bytes(&value).unwrap();
hyperium_headers.append(&name, value);
}
}
}

// Neither type is defined in this lib, so we can't do From/Into impls
fn from_uri_to_url(uri: http::Uri) -> Result<Url, crate::url::ParseError> {
fn from_uri_to_url(uri: http02::Uri) -> Result<Url, crate::url::ParseError> {
format!("{}", uri).parse()
}

// Neither type is defined in this lib, so we can't do From/Into impls
fn from_url_to_uri(url: &Url) -> http::Uri {
http::Uri::try_from(&format!("{}", url)).unwrap()
fn from_url_to_uri(url: &Url) -> http02::Uri {
http02::Uri::try_from(&format!("{}", url)).unwrap()
}

impl TryFrom<http::Request<Body>> for Request {
impl TryFrom<http02::Request<Body>> for Request {
type Error = crate::Error;

fn try_from(req: http::Request<Body>) -> Result<Self, Self::Error> {
fn try_from(req: http02::Request<Body>) -> Result<Self, Self::Error> {
let (parts, body) = req.into_parts();
let method = parts.method.into();
let url = from_uri_to_url(parts.uri)?;
@@ -194,11 +194,11 @@ impl TryFrom<http::Request<Body>> for Request {
}
}

impl From<Request> for http::Request<Body> {
impl From<Request> for http02::Request<Body> {
fn from(mut req: Request) -> Self {
let method: http::Method = req.method().into();
let method: http02::Method = req.method().into();
let version = req.version().map(|v| v.into()).unwrap_or_default();
let mut builder = http::request::Builder::new()
let mut builder = http02::request::Builder::new()
.method(method)
.uri(from_url_to_uri(req.url()))
.version(version);
@@ -207,9 +207,9 @@ impl From<Request> for http::Request<Body> {
}
}

impl TryFrom<http::Response<Body>> for Response {
impl TryFrom<http02::Response<Body>> for Response {
type Error = crate::Error;
fn try_from(res: http::Response<Body>) -> Result<Self, Self::Error> {
fn try_from(res: http02::Response<Body>) -> Result<Self, Self::Error> {
let (parts, body) = res.into_parts();
let mut res = Response::new(parts.status);
res.set_body(body);
@@ -219,11 +219,11 @@ impl TryFrom<http::Response<Body>> for Response {
}
}

impl From<Response> for http::Response<Body> {
impl From<Response> for http02::Response<Body> {
fn from(mut res: Response) -> Self {
let status: u16 = res.status().into();
let version = res.version().map(|v| v.into()).unwrap_or_default();
let mut builder = http::response::Builder::new()
let mut builder = http02::response::Builder::new()
.status(status)
.version(version);
headers_to_hyperium_headers(res.as_mut(), builder.headers_mut().unwrap());
231 changes: 231 additions & 0 deletions src/hyperium_http_1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
use crate::headers::{HeaderName, HeaderValue, Headers};
use crate::{Body, Error, Method, Request, Response, StatusCode, Url, Version};
use std::convert::{TryFrom, TryInto};
use std::str::FromStr;

impl From<http1::Method> for Method {
fn from(method: http1::Method) -> Self {
Method::from_str(method.as_str()).unwrap()
}
}

impl From<Method> for http1::Method {
fn from(method: Method) -> Self {
http1::Method::from_str(method.as_ref()).unwrap()
}
}

impl From<http1::StatusCode> for StatusCode {
fn from(status: http1::StatusCode) -> Self {
StatusCode::try_from(status.as_u16()).unwrap()
}
}

impl From<StatusCode> for http1::StatusCode {
fn from(status: StatusCode) -> Self {
http1::StatusCode::from_u16(status.into()).unwrap()
}
}

impl From<http1::Version> for Version {
fn from(version: http1::Version) -> Self {
match version {
http1::Version::HTTP_09 => Version::Http0_9,
http1::Version::HTTP_10 => Version::Http1_0,
http1::Version::HTTP_11 => Version::Http1_1,
http1::Version::HTTP_2 => Version::Http2_0,
http1::Version::HTTP_3 => Version::Http3_0,
_ => panic!("unknown http1 version conversion"),
}
}
}

impl From<Version> for http1::Version {
fn from(version: Version) -> Self {
match version {
Version::Http0_9 => http1::Version::HTTP_09,
Version::Http1_0 => http1::Version::HTTP_10,
Version::Http1_1 => http1::Version::HTTP_11,
Version::Http2_0 => http1::Version::HTTP_2,
Version::Http3_0 => http1::Version::HTTP_3,
}
}
}

impl TryFrom<http1::header::HeaderName> for HeaderName {
type Error = Error;

fn try_from(name: http1::header::HeaderName) -> Result<Self, Self::Error> {
let name = name.as_str().as_bytes().to_owned();
HeaderName::from_bytes(name)
}
}

impl TryFrom<HeaderName> for http1::header::HeaderName {
type Error = Error;

fn try_from(name: HeaderName) -> Result<Self, Self::Error> {
let name = name.as_str().as_bytes();
http1::header::HeaderName::from_bytes(name).map_err(Error::new_adhoc)
}
}

impl TryFrom<http1::header::HeaderValue> for HeaderValue {
type Error = Error;

fn try_from(value: http1::header::HeaderValue) -> Result<Self, Self::Error> {
let value = value.as_bytes().to_owned();
HeaderValue::from_bytes(value)
}
}

impl TryFrom<HeaderValue> for http1::header::HeaderValue {
type Error = Error;

fn try_from(value: HeaderValue) -> Result<Self, Self::Error> {
let value = value.as_str().as_bytes();
http1::header::HeaderValue::from_bytes(value).map_err(Error::new_adhoc)
}
}

impl TryFrom<http1::HeaderMap> for Headers {
type Error = Error;

fn try_from(hyperium_headers: http1::HeaderMap) -> Result<Self, Self::Error> {
let mut headers = Headers::new();

hyperium_headers
.into_iter()
.map(|(name, value)| {
if let Some(name) = name {
let value: HeaderValue = value.try_into()?;
let name: HeaderName = name.try_into()?;
headers.append(name, value)?;
}
Ok(())
})
.collect::<Result<Vec<()>, Error>>()?;

Ok(headers)
}
}

impl TryFrom<Headers> for http1::HeaderMap {
type Error = Error;

fn try_from(headers: Headers) -> Result<Self, Self::Error> {
let mut hyperium_headers = http1::HeaderMap::new();

headers
.into_iter()
.map(|(name, values)| {
let name: http1::header::HeaderName = name.try_into()?;

values
.into_iter()
.map(|value| {
let value: http1::header::HeaderValue = value.try_into()?;
hyperium_headers.append(&name, value);
Ok(())
})
.collect::<Result<Vec<()>, Error>>()?;

Ok(())
})
.collect::<Result<Vec<()>, Error>>()?;

Ok(hyperium_headers)
}
}

fn hyperium_headers_to_headers(
hyperium_headers: http1::HeaderMap,
headers: &mut Headers,
) -> crate::Result<()> {
for (name, value) in hyperium_headers {
let value = value.as_bytes().to_owned();
let value = unsafe { HeaderValue::from_bytes_unchecked(value) };
if let Some(name) = name {
let name = name.as_str().as_bytes().to_owned();
let name = unsafe { HeaderName::from_bytes_unchecked(name) };
headers.append(name, value)?;
}
}
Ok(())
}

fn headers_to_hyperium_headers(headers: &mut Headers, hyperium_headers: &mut http1::HeaderMap) {
for (name, values) in headers {
let name = format!("{}", name).into_bytes();
let name = http1::header::HeaderName::from_bytes(&name).unwrap();

for value in values.iter() {
let value = format!("{}", value).into_bytes();
let value = http1::header::HeaderValue::from_bytes(&value).unwrap();
hyperium_headers.append(&name, value);
}
}
}

// Neither type is defined in this lib, so we can't do From/Into impls
fn from_uri_to_url(uri: http1::Uri) -> Result<Url, crate::url::ParseError> {
format!("{}", uri).parse()
}

// Neither type is defined in this lib, so we can't do From/Into impls
fn from_url_to_uri(url: &Url) -> http1::Uri {
http1::Uri::try_from(&format!("{}", url)).unwrap()
}

impl TryFrom<http1::Request<Body>> for Request {
type Error = crate::Error;

fn try_from(req: http1::Request<Body>) -> Result<Self, Self::Error> {
let (parts, body) = req.into_parts();
let method = parts.method.into();
let url = from_uri_to_url(parts.uri)?;
let mut req = Request::new(method, url);
req.set_body(body);
req.set_version(Some(parts.version.into()));
hyperium_headers_to_headers(parts.headers, req.as_mut())?;
Ok(req)
}
}

impl From<Request> for http1::Request<Body> {
fn from(mut req: Request) -> Self {
let method: http1::Method = req.method().into();
let version = req.version().map(|v| v.into()).unwrap_or_default();
let mut builder = http1::request::Builder::new()
.method(method)
.uri(from_url_to_uri(req.url()))
.version(version);
headers_to_hyperium_headers(req.as_mut(), builder.headers_mut().unwrap());
builder.body(req.into()).unwrap()
}
}

impl TryFrom<http1::Response<Body>> for Response {
type Error = crate::Error;
fn try_from(res: http1::Response<Body>) -> Result<Self, Self::Error> {
let (parts, body) = res.into_parts();
let mut res = Response::new(parts.status);
res.set_body(body);
res.set_version(Some(parts.version.into()));
hyperium_headers_to_headers(parts.headers, res.as_mut())?;
Ok(res)
}
}

impl From<Response> for http1::Response<Body> {
fn from(mut res: Response) -> Self {
let status: u16 = res.status().into();
let version = res.version().map(|v| v.into()).unwrap_or_default();
let mut builder = http1::response::Builder::new()
.status(status)
.version(version);
headers_to_hyperium_headers(res.as_mut(), builder.headers_mut().unwrap());
let body = res.take_body();
builder.body(body).unwrap()
}
}
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -96,6 +96,7 @@
#![deny(missing_debug_implementations, nonstandard_style)]
#![warn(missing_docs)]
#![allow(clippy::new_without_default)]
#![feature(rustdoc_missing_doc_code_examples)]
#![cfg_attr(backtrace, feature(backtrace))]
#![cfg_attr(feature = "docs", feature(doc_cfg))]
#![doc(html_favicon_url = "https://yoshuawuyts.com/assets/http-rs/favicon.ico")]
@@ -158,9 +159,12 @@ pub use crate::url::Url;
pub mod security;
pub mod trailers;

#[cfg(feature = "hyperium_http")]
#[cfg(feature = "hyperium_http_02")]
mod hyperium_http;

#[cfg(feature = "hyperium_http_1")]
mod hyperium_http_1;

#[doc(inline)]
pub use crate::extensions::Extensions;

2 changes: 1 addition & 1 deletion src/security/csp.rs
Original file line number Diff line number Diff line change
@@ -160,7 +160,7 @@ impl ContentSecurityPolicy {

fn insert_directive<T: AsRef<str>>(&mut self, directive: &str, source: T) {
let directive = String::from(directive);
let directives = self.directives.entry(directive).or_insert_with(Vec::new);
let directives = self.directives.entry(directive).or_default();
let source: String = source.as_ref().to_string();
directives.push(source);
}
8 changes: 5 additions & 3 deletions src/trailers.rs
Original file line number Diff line number Diff line change
@@ -242,20 +242,22 @@ impl Sender {
#[must_use = "Futures do nothing unless polled or .awaited"]
#[derive(Debug)]
pub struct Receiver {
receiver: async_channel::Receiver<Trailers>,
receiver: Pin<Box<async_channel::Receiver<Trailers>>>,
}

impl Receiver {
/// Create a new instance of `Receiver`.
pub(crate) fn new(receiver: async_channel::Receiver<Trailers>) -> Self {
Self { receiver }
Self {
receiver: Box::pin(receiver),
}
}
}

impl Future for Receiver {
type Output = Option<Trailers>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
Pin::new(&mut self.receiver).poll_next(cx)
self.receiver.as_mut().poll_next(cx)
}
}
8 changes: 5 additions & 3 deletions src/upgrade/receiver.rs
Original file line number Diff line number Diff line change
@@ -10,21 +10,23 @@ use crate::upgrade::Connection;
#[must_use = "Futures do nothing unless polled or .awaited"]
#[derive(Debug)]
pub struct Receiver {
receiver: async_channel::Receiver<Connection>,
receiver: Pin<Box<async_channel::Receiver<Connection>>>,
}

impl Receiver {
/// Create a new instance of `Receiver`.
#[allow(unused)]
pub(crate) fn new(receiver: async_channel::Receiver<Connection>) -> Self {
Self { receiver }
Self {
receiver: Box::pin(receiver),
}
}
}

impl Future for Receiver {
type Output = Option<Connection>;

fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
Pin::new(&mut self.receiver).poll_next(cx)
self.receiver.as_mut().poll_next(cx)
}
}
16 changes: 8 additions & 8 deletions src/utils/date.rs
Original file line number Diff line number Diff line change
@@ -378,21 +378,21 @@ impl Display for HttpDate {
buf[0] = week_day[0];
buf[1] = week_day[1];
buf[2] = week_day[2];
buf[5] = b'0' + (self.day / 10) as u8;
buf[6] = b'0' + (self.day % 10) as u8;
buf[5] = b'0' + (self.day / 10);
buf[6] = b'0' + (self.day % 10);
buf[8] = month[0];
buf[9] = month[1];
buf[10] = month[2];
buf[12] = b'0' + (self.year / 1000) as u8;
buf[13] = b'0' + (self.year / 100 % 10) as u8;
buf[14] = b'0' + (self.year / 10 % 10) as u8;
buf[15] = b'0' + (self.year % 10) as u8;
buf[17] = b'0' + (self.hour / 10) as u8;
buf[18] = b'0' + (self.hour % 10) as u8;
buf[20] = b'0' + (self.minute / 10) as u8;
buf[21] = b'0' + (self.minute % 10) as u8;
buf[23] = b'0' + (self.second / 10) as u8;
buf[24] = b'0' + (self.second % 10) as u8;
buf[17] = b'0' + (self.hour / 10);
buf[18] = b'0' + (self.hour % 10);
buf[20] = b'0' + (self.minute / 10);
buf[21] = b'0' + (self.minute % 10);
buf[23] = b'0' + (self.second / 10);
buf[24] = b'0' + (self.second % 10);
f.write_str(from_utf8(&buf[..]).unwrap())
}
}