1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-07-02 04:34:32 +02:00

actix-web beta 15 updates (#216)

This commit is contained in:
Rob Ede
2021-12-18 03:37:23 +00:00
committed by GitHub
parent c047cd5653
commit 6676a50944
26 changed files with 101 additions and 82 deletions

View File

@ -1,12 +1,11 @@
use std::borrow::Cow;
use std::fmt;
use std::str;
use std::{borrow::Cow, fmt, str};
use actix_web::http::header::{HeaderValue, IntoHeaderValue, InvalidHeaderValue};
use actix_web::web::{BufMut, BytesMut};
use actix_web::{
http::header::{HeaderValue, InvalidHeaderValue, TryIntoHeaderValue},
web::{BufMut, BytesMut},
};
use crate::headers::authorization::errors::ParseError;
use crate::headers::authorization::Scheme;
use crate::headers::authorization::{errors::ParseError, Scheme};
/// Credentials for `Basic` authentication scheme, defined in [RFC 7617](https://tools.ietf.org/html/rfc7617)
#[derive(Clone, Eq, Ord, PartialEq, PartialOrd)]
@ -94,10 +93,10 @@ impl fmt::Display for Basic {
}
}
impl IntoHeaderValue for Basic {
impl TryIntoHeaderValue for Basic {
type Error = InvalidHeaderValue;
fn try_into_value(self) -> Result<HeaderValue, <Self as IntoHeaderValue>::Error> {
fn try_into_value(self) -> Result<HeaderValue, Self::Error> {
let mut credentials = BytesMut::with_capacity(
self.user_id.len()
+ 1 // ':'
@ -123,8 +122,7 @@ impl IntoHeaderValue for Basic {
#[cfg(test)]
mod tests {
use super::{Basic, Scheme};
use actix_web::http::header::{HeaderValue, IntoHeaderValue};
use super::*;
#[test]
fn test_parse_header() {