mirror of https://github.com/fafhrd91/actix-web
rename trait to TryIntoHeaderValue
This commit is contained in:
parent
afc9aa4c92
commit
44005e216e
10
CHANGES.md
10
CHANGES.md
|
@ -2,12 +2,16 @@
|
|||
|
||||
## Unreleased - 2021-xx-xx
|
||||
### Added
|
||||
* Method on `Responder` trait (`customize`) for customizing responders and `CustomizeResponder` struct. [#????]
|
||||
* Method on `Responder` trait (`customize`) for customizing responders and `CustomizeResponder` struct. [#2510]
|
||||
* Implement `Debug` for `DefaultHeaders`. [#2510]
|
||||
|
||||
### Changed
|
||||
* Align `DefaultHeader` method terminology, deprecating previous methods. [#????]
|
||||
* Align `DefaultHeader` method terminology, deprecating previous methods. [#2510]
|
||||
|
||||
[#????]: https://github.com/actix/actix-web/pull/????
|
||||
### Removed
|
||||
* Top-level `EitherExtractError` export. [#2510]
|
||||
|
||||
[#2510]: https://github.com/actix/actix-web/pull/2510
|
||||
|
||||
|
||||
## 4.0.0-beta.14 - 2021-12-11
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
## Unreleased - 2021-xx-xx
|
||||
### Changed
|
||||
* Rename trait `IntoHeaderPair => TryIntoHeaderPair`. [#????]
|
||||
* Rename trait `IntoHeaderPair => TryIntoHeaderPair`. [#2510]
|
||||
* Rename trait `IntoHeaderValue => TryIntoHeaderValue`. [#2510]
|
||||
|
||||
[#????]: https://github.com/actix/actix-web/pull/????
|
||||
[#2510]: https://github.com/actix/actix-web/pull/2510
|
||||
|
||||
|
||||
## 3.0.0-beta.15 - 2021-12-11
|
||||
|
@ -275,9 +276,9 @@
|
|||
* `trust-dns` optional feature to enable `trust-dns-resolver` as client dns resolver. [#1969]
|
||||
|
||||
### Changed
|
||||
* `ResponseBuilder::content_type` now takes an `impl IntoHeaderValue` to support using typed
|
||||
* `ResponseBuilder::content_type` now takes an `impl TryIntoHeaderValue` to support using typed
|
||||
`mime` types. [#1894]
|
||||
* Renamed `IntoHeaderValue::{try_into => try_into_value}` to avoid ambiguity with std
|
||||
* Renamed `TryIntoHeaderValue::{try_into => try_into_value}` to avoid ambiguity with std
|
||||
`TryInto` trait. [#1894]
|
||||
* `Extensions::insert` returns Option of replaced item. [#1904]
|
||||
* Remove `HttpResponseBuilder::json2()`. [#1903]
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
use std::convert::TryFrom as _;
|
||||
|
||||
use super::{
|
||||
Header, HeaderName, HeaderValue, IntoHeaderValue, InvalidHeaderName, InvalidHeaderValue,
|
||||
Header, HeaderName, HeaderValue, InvalidHeaderName, InvalidHeaderValue, TryIntoHeaderValue,
|
||||
};
|
||||
use crate::error::HttpError;
|
||||
|
||||
|
@ -34,7 +34,7 @@ impl From<InvalidHeaderPart> for HttpError {
|
|||
|
||||
impl<V> TryIntoHeaderPair for (HeaderName, V)
|
||||
where
|
||||
V: IntoHeaderValue,
|
||||
V: TryIntoHeaderValue,
|
||||
V::Error: Into<InvalidHeaderValue>,
|
||||
{
|
||||
type Error = InvalidHeaderPart;
|
||||
|
@ -50,7 +50,7 @@ where
|
|||
|
||||
impl<V> TryIntoHeaderPair for (&HeaderName, V)
|
||||
where
|
||||
V: IntoHeaderValue,
|
||||
V: TryIntoHeaderValue,
|
||||
V::Error: Into<InvalidHeaderValue>,
|
||||
{
|
||||
type Error = InvalidHeaderPart;
|
||||
|
@ -66,7 +66,7 @@ where
|
|||
|
||||
impl<V> TryIntoHeaderPair for (&[u8], V)
|
||||
where
|
||||
V: IntoHeaderValue,
|
||||
V: TryIntoHeaderValue,
|
||||
V::Error: Into<InvalidHeaderValue>,
|
||||
{
|
||||
type Error = InvalidHeaderPart;
|
||||
|
@ -83,7 +83,7 @@ where
|
|||
|
||||
impl<V> TryIntoHeaderPair for (&str, V)
|
||||
where
|
||||
V: IntoHeaderValue,
|
||||
V: TryIntoHeaderValue,
|
||||
V::Error: Into<InvalidHeaderValue>,
|
||||
{
|
||||
type Error = InvalidHeaderPart;
|
||||
|
@ -100,7 +100,7 @@ where
|
|||
|
||||
impl<V> TryIntoHeaderPair for (String, V)
|
||||
where
|
||||
V: IntoHeaderValue,
|
||||
V: TryIntoHeaderValue,
|
||||
V::Error: Into<InvalidHeaderValue>,
|
||||
{
|
||||
type Error = InvalidHeaderPart;
|
||||
|
@ -113,7 +113,7 @@ where
|
|||
}
|
||||
|
||||
impl<T: Header> TryIntoHeaderPair for T {
|
||||
type Error = <T as IntoHeaderValue>::Error;
|
||||
type Error = <T as TryIntoHeaderValue>::Error;
|
||||
|
||||
#[inline]
|
||||
fn try_into_header_pair(self) -> Result<(HeaderName, HeaderValue), Self::Error> {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//! [`IntoHeaderValue`] trait and implementations.
|
||||
//! [`TryIntoHeaderValue`] trait and implementations.
|
||||
|
||||
use std::convert::TryFrom as _;
|
||||
|
||||
|
@ -7,7 +7,7 @@ use http::{header::InvalidHeaderValue, Error as HttpError, HeaderValue};
|
|||
use mime::Mime;
|
||||
|
||||
/// An interface for types that can be converted into a [`HeaderValue`].
|
||||
pub trait IntoHeaderValue: Sized {
|
||||
pub trait TryIntoHeaderValue: Sized {
|
||||
/// The type returned in the event of a conversion error.
|
||||
type Error: Into<HttpError>;
|
||||
|
||||
|
@ -15,7 +15,7 @@ pub trait IntoHeaderValue: Sized {
|
|||
fn try_into_value(self) -> Result<HeaderValue, Self::Error>;
|
||||
}
|
||||
|
||||
impl IntoHeaderValue for HeaderValue {
|
||||
impl TryIntoHeaderValue for HeaderValue {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
#[inline]
|
||||
|
@ -24,7 +24,7 @@ impl IntoHeaderValue for HeaderValue {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoHeaderValue for &HeaderValue {
|
||||
impl TryIntoHeaderValue for &HeaderValue {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
#[inline]
|
||||
|
@ -33,7 +33,7 @@ impl IntoHeaderValue for &HeaderValue {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoHeaderValue for &str {
|
||||
impl TryIntoHeaderValue for &str {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
#[inline]
|
||||
|
@ -42,7 +42,7 @@ impl IntoHeaderValue for &str {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoHeaderValue for &[u8] {
|
||||
impl TryIntoHeaderValue for &[u8] {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
#[inline]
|
||||
|
@ -51,7 +51,7 @@ impl IntoHeaderValue for &[u8] {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoHeaderValue for Bytes {
|
||||
impl TryIntoHeaderValue for Bytes {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
#[inline]
|
||||
|
@ -60,7 +60,7 @@ impl IntoHeaderValue for Bytes {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoHeaderValue for Vec<u8> {
|
||||
impl TryIntoHeaderValue for Vec<u8> {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
#[inline]
|
||||
|
@ -69,7 +69,7 @@ impl IntoHeaderValue for Vec<u8> {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoHeaderValue for String {
|
||||
impl TryIntoHeaderValue for String {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
#[inline]
|
||||
|
@ -78,7 +78,7 @@ impl IntoHeaderValue for String {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoHeaderValue for usize {
|
||||
impl TryIntoHeaderValue for usize {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
#[inline]
|
||||
|
@ -87,7 +87,7 @@ impl IntoHeaderValue for usize {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoHeaderValue for i64 {
|
||||
impl TryIntoHeaderValue for i64 {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
#[inline]
|
||||
|
@ -96,7 +96,7 @@ impl IntoHeaderValue for i64 {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoHeaderValue for u64 {
|
||||
impl TryIntoHeaderValue for u64 {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
#[inline]
|
||||
|
@ -105,7 +105,7 @@ impl IntoHeaderValue for u64 {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoHeaderValue for i32 {
|
||||
impl TryIntoHeaderValue for i32 {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
#[inline]
|
||||
|
@ -114,7 +114,7 @@ impl IntoHeaderValue for i32 {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoHeaderValue for u32 {
|
||||
impl TryIntoHeaderValue for u32 {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
#[inline]
|
||||
|
@ -123,7 +123,7 @@ impl IntoHeaderValue for u32 {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoHeaderValue for Mime {
|
||||
impl TryIntoHeaderValue for Mime {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -38,7 +38,7 @@ mod utils;
|
|||
|
||||
pub use self::as_name::AsHeaderName;
|
||||
pub use self::into_pair::TryIntoHeaderPair;
|
||||
pub use self::into_value::IntoHeaderValue;
|
||||
pub use self::into_value::TryIntoHeaderValue;
|
||||
pub use self::map::HeaderMap;
|
||||
pub use self::shared::{
|
||||
parse_extended_value, q, Charset, ContentEncoding, ExtendedValue, HttpDate, LanguageTag,
|
||||
|
@ -49,7 +49,7 @@ pub use self::utils::{
|
|||
};
|
||||
|
||||
/// An interface for types that already represent a valid header.
|
||||
pub trait Header: IntoHeaderValue {
|
||||
pub trait Header: TryIntoHeaderValue {
|
||||
/// Returns the name of the header field
|
||||
fn name() -> HeaderName;
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use http::header::InvalidHeaderValue;
|
|||
|
||||
use crate::{
|
||||
error::ParseError,
|
||||
header::{self, from_one_raw_str, Header, HeaderName, HeaderValue, IntoHeaderValue},
|
||||
header::{self, from_one_raw_str, Header, HeaderName, HeaderValue, TryIntoHeaderValue},
|
||||
HttpMessage,
|
||||
};
|
||||
|
||||
|
@ -96,7 +96,7 @@ impl TryFrom<&str> for ContentEncoding {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoHeaderValue for ContentEncoding {
|
||||
impl TryIntoHeaderValue for ContentEncoding {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
fn try_into_value(self) -> Result<http::HeaderValue, Self::Error> {
|
||||
|
|
|
@ -4,7 +4,8 @@ use bytes::BytesMut;
|
|||
use http::header::{HeaderValue, InvalidHeaderValue};
|
||||
|
||||
use crate::{
|
||||
config::DATE_VALUE_LENGTH, error::ParseError, header::IntoHeaderValue, helpers::MutWriter,
|
||||
config::DATE_VALUE_LENGTH, error::ParseError, header::TryIntoHeaderValue,
|
||||
helpers::MutWriter,
|
||||
};
|
||||
|
||||
/// A timestamp with HTTP-style formatting and parsing.
|
||||
|
@ -29,7 +30,7 @@ impl fmt::Display for HttpDate {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoHeaderValue for HttpDate {
|
||||
impl TryIntoHeaderValue for HttpDate {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
fn try_into_value(self) -> Result<HeaderValue, Self::Error> {
|
||||
|
|
|
@ -11,7 +11,7 @@ use bytestring::ByteString;
|
|||
use crate::{
|
||||
body::{BoxBody, MessageBody},
|
||||
extensions::Extensions,
|
||||
header::{self, HeaderMap, IntoHeaderValue},
|
||||
header::{self, HeaderMap, TryIntoHeaderValue},
|
||||
message::{BoxedResponseHead, ResponseHead},
|
||||
Error, ResponseBuilder, StatusCode,
|
||||
};
|
||||
|
|
|
@ -8,7 +8,7 @@ use std::{
|
|||
use crate::{
|
||||
body::{EitherBody, MessageBody},
|
||||
error::{Error, HttpError},
|
||||
header::{self, IntoHeaderValue, TryIntoHeaderPair},
|
||||
header::{self, TryIntoHeaderPair, TryIntoHeaderValue},
|
||||
message::{BoxedResponseHead, ConnectionType, ResponseHead},
|
||||
Extensions, Response, StatusCode,
|
||||
};
|
||||
|
@ -151,7 +151,7 @@ impl ResponseBuilder {
|
|||
#[inline]
|
||||
pub fn upgrade<V>(&mut self, value: V) -> &mut Self
|
||||
where
|
||||
V: IntoHeaderValue,
|
||||
V: TryIntoHeaderValue,
|
||||
{
|
||||
if let Some(parts) = self.inner() {
|
||||
parts.set_connection_type(ConnectionType::Upgrade);
|
||||
|
@ -189,7 +189,7 @@ impl ResponseBuilder {
|
|||
#[inline]
|
||||
pub fn content_type<V>(&mut self, value: V) -> &mut Self
|
||||
where
|
||||
V: IntoHeaderValue,
|
||||
V: TryIntoHeaderValue,
|
||||
{
|
||||
if let Some(parts) = self.inner() {
|
||||
match value.try_into_value() {
|
||||
|
|
|
@ -166,7 +166,7 @@ where
|
|||
where
|
||||
HeaderName: TryFrom<K>,
|
||||
<HeaderName as TryFrom<K>>::Error: fmt::Debug + Into<HttpError>,
|
||||
V: header::IntoHeaderValue,
|
||||
V: header::TryIntoHeaderValue,
|
||||
V::Error: fmt::Debug,
|
||||
{
|
||||
match HeaderName::try_from(key) {
|
||||
|
|
|
@ -9,7 +9,7 @@ use actix_http::{
|
|||
body::{BodySize, MessageBody},
|
||||
error::PayloadError,
|
||||
h1,
|
||||
header::{HeaderMap, IntoHeaderValue, EXPECT, HOST},
|
||||
header::{HeaderMap, TryIntoHeaderValue, EXPECT, HOST},
|
||||
Payload, RequestHeadType, ResponseHead, StatusCode,
|
||||
};
|
||||
use actix_utils::future::poll_fn;
|
||||
|
|
|
@ -6,7 +6,7 @@ use serde::Serialize;
|
|||
|
||||
use actix_http::{
|
||||
error::HttpError,
|
||||
header::{HeaderMap, HeaderName, IntoHeaderValue},
|
||||
header::{HeaderMap, HeaderName, TryIntoHeaderValue},
|
||||
Method, RequestHead, Uri,
|
||||
};
|
||||
|
||||
|
@ -114,7 +114,7 @@ impl FrozenClientRequest {
|
|||
where
|
||||
HeaderName: TryFrom<K>,
|
||||
<HeaderName as TryFrom<K>>::Error: Into<HttpError>,
|
||||
V: IntoHeaderValue,
|
||||
V: TryIntoHeaderValue,
|
||||
{
|
||||
self.extra_headers(HeaderMap::new())
|
||||
.extra_header(key, value)
|
||||
|
@ -142,7 +142,7 @@ impl FrozenSendBuilder {
|
|||
where
|
||||
HeaderName: TryFrom<K>,
|
||||
<HeaderName as TryFrom<K>>::Error: Into<HttpError>,
|
||||
V: IntoHeaderValue,
|
||||
V: TryIntoHeaderValue,
|
||||
{
|
||||
match HeaderName::try_from(key) {
|
||||
Ok(key) => match value.try_into_value() {
|
||||
|
|
|
@ -10,7 +10,7 @@ use std::{
|
|||
use actix_http::{
|
||||
body::BodyStream,
|
||||
error::HttpError,
|
||||
header::{self, HeaderMap, HeaderName, IntoHeaderValue},
|
||||
header::{self, HeaderMap, HeaderName, TryIntoHeaderValue},
|
||||
RequestHead, RequestHeadType,
|
||||
};
|
||||
use actix_rt::time::{sleep, Sleep};
|
||||
|
@ -298,7 +298,7 @@ impl RequestSender {
|
|||
|
||||
fn set_header_if_none<V>(&mut self, key: HeaderName, value: V) -> Result<(), HttpError>
|
||||
where
|
||||
V: IntoHeaderValue,
|
||||
V: TryIntoHeaderValue,
|
||||
{
|
||||
match self {
|
||||
RequestSender::Owned(head) => {
|
||||
|
|
|
@ -39,7 +39,7 @@ use crate::{
|
|||
connect::{BoxedSocket, ConnectRequest},
|
||||
error::{HttpError, InvalidUrl, SendRequestError, WsClientError},
|
||||
http::{
|
||||
header::{self, HeaderName, HeaderValue, IntoHeaderValue, AUTHORIZATION},
|
||||
header::{self, HeaderName, HeaderValue, TryIntoHeaderValue, AUTHORIZATION},
|
||||
ConnectionType, Method, StatusCode, Uri, Version,
|
||||
},
|
||||
response::ClientResponse,
|
||||
|
@ -171,7 +171,7 @@ impl WebsocketsRequest {
|
|||
where
|
||||
HeaderName: TryFrom<K>,
|
||||
<HeaderName as TryFrom<K>>::Error: Into<HttpError>,
|
||||
V: IntoHeaderValue,
|
||||
V: TryIntoHeaderValue,
|
||||
{
|
||||
match HeaderName::try_from(key) {
|
||||
Ok(key) => match value.try_into_value() {
|
||||
|
@ -190,7 +190,7 @@ impl WebsocketsRequest {
|
|||
where
|
||||
HeaderName: TryFrom<K>,
|
||||
<HeaderName as TryFrom<K>>::Error: Into<HttpError>,
|
||||
V: IntoHeaderValue,
|
||||
V: TryIntoHeaderValue,
|
||||
{
|
||||
match HeaderName::try_from(key) {
|
||||
Ok(key) => match value.try_into_value() {
|
||||
|
@ -209,7 +209,7 @@ impl WebsocketsRequest {
|
|||
where
|
||||
HeaderName: TryFrom<K>,
|
||||
<HeaderName as TryFrom<K>>::Error: Into<HttpError>,
|
||||
V: IntoHeaderValue,
|
||||
V: TryIntoHeaderValue,
|
||||
{
|
||||
match HeaderName::try_from(key) {
|
||||
Ok(key) => {
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::{cell::RefCell, fmt, io::Write as _};
|
|||
|
||||
use actix_http::{
|
||||
body::BoxBody,
|
||||
header::{self, IntoHeaderValue as _},
|
||||
header::{self, TryIntoHeaderValue as _},
|
||||
StatusCode,
|
||||
};
|
||||
use bytes::{BufMut as _, BytesMut};
|
||||
|
|
|
@ -8,7 +8,7 @@ use std::{
|
|||
|
||||
use actix_http::{
|
||||
body::BoxBody,
|
||||
header::{self, IntoHeaderValue},
|
||||
header::{self, TryIntoHeaderValue},
|
||||
Response, StatusCode,
|
||||
};
|
||||
use bytes::BytesMut;
|
||||
|
|
|
@ -14,7 +14,7 @@ use once_cell::sync::Lazy;
|
|||
use regex::Regex;
|
||||
use std::fmt::{self, Write};
|
||||
|
||||
use super::{ExtendedValue, Header, IntoHeaderValue, Writer};
|
||||
use super::{ExtendedValue, Header, TryIntoHeaderValue, Writer};
|
||||
use crate::http::header;
|
||||
|
||||
/// Split at the index of the first `needle` if it exists or at the end.
|
||||
|
@ -454,7 +454,7 @@ impl ContentDisposition {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoHeaderValue for ContentDisposition {
|
||||
impl TryIntoHeaderValue for ContentDisposition {
|
||||
type Error = header::InvalidHeaderValue;
|
||||
|
||||
fn try_into_value(self) -> Result<header::HeaderValue, Self::Error> {
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::{
|
|||
str::FromStr,
|
||||
};
|
||||
|
||||
use super::{HeaderValue, IntoHeaderValue, InvalidHeaderValue, Writer, CONTENT_RANGE};
|
||||
use super::{HeaderValue, InvalidHeaderValue, TryIntoHeaderValue, Writer, CONTENT_RANGE};
|
||||
use crate::error::ParseError;
|
||||
|
||||
crate::http::header::common_header! {
|
||||
|
@ -196,7 +196,7 @@ impl Display for ContentRangeSpec {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoHeaderValue for ContentRangeSpec {
|
||||
impl TryIntoHeaderValue for ContentRangeSpec {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
fn try_into_value(self) -> Result<HeaderValue, Self::Error> {
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::{
|
|||
str::FromStr,
|
||||
};
|
||||
|
||||
use super::{HeaderValue, IntoHeaderValue, InvalidHeaderValue, Writer};
|
||||
use super::{HeaderValue, InvalidHeaderValue, TryIntoHeaderValue, Writer};
|
||||
|
||||
/// check that each char in the slice is either:
|
||||
/// 1. `%x21`, or
|
||||
|
@ -159,7 +159,7 @@ impl FromStr for EntityTag {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoHeaderValue for EntityTag {
|
||||
impl TryIntoHeaderValue for EntityTag {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
fn try_into_value(self) -> Result<HeaderValue, Self::Error> {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use std::fmt::{self, Display, Write};
|
||||
|
||||
use super::{
|
||||
from_one_raw_str, EntityTag, Header, HeaderName, HeaderValue, HttpDate, IntoHeaderValue,
|
||||
InvalidHeaderValue, Writer,
|
||||
from_one_raw_str, EntityTag, Header, HeaderName, HeaderValue, HttpDate, InvalidHeaderValue,
|
||||
TryIntoHeaderValue, Writer,
|
||||
};
|
||||
use crate::error::ParseError;
|
||||
use crate::http::header;
|
||||
|
@ -96,7 +96,7 @@ impl Display for IfRange {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoHeaderValue for IfRange {
|
||||
impl TryIntoHeaderValue for IfRange {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
fn try_into_value(self) -> Result<HeaderValue, Self::Error> {
|
||||
|
|
|
@ -125,7 +125,7 @@ macro_rules! common_header {
|
|||
}
|
||||
}
|
||||
|
||||
impl $crate::http::header::IntoHeaderValue for $id {
|
||||
impl $crate::http::header::TryIntoHeaderValue for $id {
|
||||
type Error = $crate::http::header::InvalidHeaderValue;
|
||||
|
||||
#[inline]
|
||||
|
@ -172,7 +172,7 @@ macro_rules! common_header {
|
|||
}
|
||||
}
|
||||
|
||||
impl $crate::http::header::IntoHeaderValue for $id {
|
||||
impl $crate::http::header::TryIntoHeaderValue for $id {
|
||||
type Error = $crate::http::header::InvalidHeaderValue;
|
||||
|
||||
#[inline]
|
||||
|
@ -211,7 +211,7 @@ macro_rules! common_header {
|
|||
}
|
||||
}
|
||||
|
||||
impl $crate::http::header::IntoHeaderValue for $id {
|
||||
impl $crate::http::header::TryIntoHeaderValue for $id {
|
||||
type Error = $crate::http::header::InvalidHeaderValue;
|
||||
|
||||
#[inline]
|
||||
|
@ -266,7 +266,7 @@ macro_rules! common_header {
|
|||
}
|
||||
}
|
||||
|
||||
impl $crate::http::header::IntoHeaderValue for $id {
|
||||
impl $crate::http::header::TryIntoHeaderValue for $id {
|
||||
type Error = $crate::http::header::InvalidHeaderValue;
|
||||
|
||||
#[inline]
|
||||
|
|
|
@ -6,7 +6,7 @@ use std::{
|
|||
|
||||
use actix_http::{error::ParseError, header, HttpMessage};
|
||||
|
||||
use super::{Header, HeaderName, HeaderValue, IntoHeaderValue, InvalidHeaderValue, Writer};
|
||||
use super::{Header, HeaderName, HeaderValue, InvalidHeaderValue, TryIntoHeaderValue, Writer};
|
||||
|
||||
/// `Range` header, defined
|
||||
/// in [RFC 7233 §3.1](https://datatracker.ietf.org/doc/html/rfc7233#section-3.1)
|
||||
|
@ -274,7 +274,7 @@ impl Header for Range {
|
|||
}
|
||||
}
|
||||
|
||||
impl IntoHeaderValue for Range {
|
||||
impl TryIntoHeaderValue for Range {
|
||||
type Error = InvalidHeaderValue;
|
||||
|
||||
fn try_into_value(self) -> Result<HeaderValue, Self::Error> {
|
||||
|
|
|
@ -75,7 +75,10 @@ impl DefaultHeaders {
|
|||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
#[deprecated(since = "4.0.0", note = "Prefer `add`.")]
|
||||
#[deprecated(
|
||||
since = "4.0.0",
|
||||
note = "Prefer `.add((key, value))`. Will be removed in v5."
|
||||
)]
|
||||
pub fn header<K, V>(self, key: K, value: V) -> Self
|
||||
where
|
||||
HeaderName: TryFrom<K>,
|
||||
|
|
|
@ -9,7 +9,7 @@ use std::{
|
|||
use actix_http::{
|
||||
body::{BodyStream, BoxBody, MessageBody},
|
||||
error::HttpError,
|
||||
header::{self, HeaderName, IntoHeaderValue, TryIntoHeaderPair},
|
||||
header::{self, HeaderName, TryIntoHeaderPair, TryIntoHeaderValue},
|
||||
ConnectionType, Extensions, Response, ResponseHead, StatusCode,
|
||||
};
|
||||
use bytes::Bytes;
|
||||
|
@ -112,7 +112,7 @@ impl HttpResponseBuilder {
|
|||
where
|
||||
K: TryInto<HeaderName>,
|
||||
K::Error: Into<HttpError>,
|
||||
V: IntoHeaderValue,
|
||||
V: TryIntoHeaderValue,
|
||||
{
|
||||
if self.err.is_some() {
|
||||
return self;
|
||||
|
@ -137,7 +137,7 @@ impl HttpResponseBuilder {
|
|||
where
|
||||
K: TryInto<HeaderName>,
|
||||
K::Error: Into<HttpError>,
|
||||
V: IntoHeaderValue,
|
||||
V: TryIntoHeaderValue,
|
||||
{
|
||||
if self.err.is_some() {
|
||||
return self;
|
||||
|
@ -174,7 +174,7 @@ impl HttpResponseBuilder {
|
|||
#[inline]
|
||||
pub fn upgrade<V>(&mut self, value: V) -> &mut Self
|
||||
where
|
||||
V: IntoHeaderValue,
|
||||
V: TryIntoHeaderValue,
|
||||
{
|
||||
if let Some(parts) = self.inner() {
|
||||
parts.set_connection_type(ConnectionType::Upgrade);
|
||||
|
@ -212,7 +212,7 @@ impl HttpResponseBuilder {
|
|||
#[inline]
|
||||
pub fn content_type<V>(&mut self, value: V) -> &mut Self
|
||||
where
|
||||
V: IntoHeaderValue,
|
||||
V: TryIntoHeaderValue,
|
||||
{
|
||||
if let Some(parts) = self.inner() {
|
||||
match value.try_into_value() {
|
||||
|
|
|
@ -48,7 +48,7 @@ pub trait Responder {
|
|||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
#[deprecated(since = "4.0.0", note = "Prefer `.customize().insert_header()`.")]
|
||||
#[deprecated(since = "4.0.0", note = "Prefer `.customize().insert_header(header)`.")]
|
||||
fn with_header(self, header: impl TryIntoHeaderPair) -> CustomizeResponder<Self>
|
||||
where
|
||||
Self: Sized,
|
||||
|
|
Loading…
Reference in New Issue