Skip to content
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

Updated dependencies #521

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
34 changes: 17 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,31 +27,31 @@ fs = ["async-std"]
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 }
http = { version = "1.0.0", optional = true }
AlexSherbinin marked this conversation as resolved.
Show resolved Hide resolved

# 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"] }
http = "1.0.0"
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::{
Expand Down Expand Up @@ -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, ':');
Expand Down Expand Up @@ -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()
}
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
#![deny(missing_debug_implementations, nonstandard_style)]
#![warn(missing_docs)]
#![allow(clippy::new_without_default)]
#![feature(rustdoc_missing_doc_code_examples)]

Check failure on line 99 in src/lib.rs

View workflow job for this annotation

GitHub Actions / Build and test (ubuntu-latest, stable)

`#![feature]` may not be used on the stable release channel
#![cfg_attr(backtrace, feature(backtrace))]
#![cfg_attr(feature = "docs", feature(doc_cfg))]
#![doc(html_favicon_url = "https://yoshuawuyts.com/assets/http-rs/favicon.ico")]
Expand Down
2 changes: 1 addition & 1 deletion src/security/csp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
8 changes: 5 additions & 3 deletions src/trailers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Up @@ -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
Expand Up @@ -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())
}
}
Expand Down
Loading