mirror of https://github.com/fafhrd91/actix-web
parent
e72ee28232
commit
7946fa7faa
|
@ -43,7 +43,7 @@ default = ["compress"]
|
||||||
# content-encoding support
|
# content-encoding support
|
||||||
compress = ["actix-http/compress", "awc/compress"]
|
compress = ["actix-http/compress", "awc/compress"]
|
||||||
|
|
||||||
# sessions feature, session require "ring" crate and c compiler
|
# sessions feature
|
||||||
secure-cookies = ["actix-http/secure-cookies"]
|
secure-cookies = ["actix-http/secure-cookies"]
|
||||||
|
|
||||||
# openssl
|
# openssl
|
||||||
|
|
|
@ -34,7 +34,7 @@ rustls = ["actix-tls/rustls", "actix-connect/rustls"]
|
||||||
compress = ["flate2", "brotli2"]
|
compress = ["flate2", "brotli2"]
|
||||||
|
|
||||||
# support for secure cookies
|
# support for secure cookies
|
||||||
secure-cookies = ["ring"]
|
secure-cookies = ["cookie/secure"]
|
||||||
|
|
||||||
# support for actix Actor messages
|
# support for actix Actor messages
|
||||||
actors = ["actix"]
|
actors = ["actix"]
|
||||||
|
@ -52,6 +52,7 @@ actix = { version = "0.10.0-alpha.1", optional = true }
|
||||||
base64 = "0.12"
|
base64 = "0.12"
|
||||||
bitflags = "1.2"
|
bitflags = "1.2"
|
||||||
bytes = "0.5.3"
|
bytes = "0.5.3"
|
||||||
|
cookie = { version = "0.14.1", features = ["percent-encode"] }
|
||||||
copyless = "0.1.4"
|
copyless = "0.1.4"
|
||||||
derive_more = "0.99.2"
|
derive_more = "0.99.2"
|
||||||
either = "1.5.3"
|
either = "1.5.3"
|
||||||
|
@ -69,7 +70,7 @@ lazy_static = "1.4"
|
||||||
language-tags = "0.2"
|
language-tags = "0.2"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
mime = "0.3"
|
mime = "0.3"
|
||||||
percent-encoding = "2.1"
|
percent-encoding = "2.1" # TODO: remove
|
||||||
pin-project = "0.4.17"
|
pin-project = "0.4.17"
|
||||||
rand = "0.7"
|
rand = "0.7"
|
||||||
regex = "1.3"
|
regex = "1.3"
|
||||||
|
@ -81,7 +82,7 @@ serde_urlencoded = "0.6.1"
|
||||||
time = { version = "0.2.7", default-features = false, features = ["std"] }
|
time = { version = "0.2.7", default-features = false, features = ["std"] }
|
||||||
|
|
||||||
# for secure cookie
|
# for secure cookie
|
||||||
ring = { version = "0.16.9", optional = true }
|
ring = { version = "0.16.9", optional = true } # TODO: remove
|
||||||
|
|
||||||
# compression
|
# compression
|
||||||
brotli2 = { version="0.3.2", optional = true }
|
brotli2 = { version="0.3.2", optional = true }
|
||||||
|
|
|
@ -32,7 +32,7 @@ mod response;
|
||||||
mod service;
|
mod service;
|
||||||
mod time_parser;
|
mod time_parser;
|
||||||
|
|
||||||
pub mod cookie;
|
pub use cookie;
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod h1;
|
pub mod h1;
|
||||||
pub mod h2;
|
pub mod h2;
|
||||||
|
|
|
@ -877,7 +877,7 @@ mod tests {
|
||||||
.domain("www.rust-lang.org")
|
.domain("www.rust-lang.org")
|
||||||
.path("/test")
|
.path("/test")
|
||||||
.http_only(true)
|
.http_only(true)
|
||||||
.max_age_time(time::Duration::days(1))
|
.max_age(time::Duration::days(1))
|
||||||
.finish(),
|
.finish(),
|
||||||
)
|
)
|
||||||
.del_cookie(&cookies[1])
|
.del_cookie(&cookies[1])
|
||||||
|
|
|
@ -10,9 +10,8 @@ use actix_codec::{AsyncRead, AsyncWrite};
|
||||||
use bytes::{Bytes, BytesMut};
|
use bytes::{Bytes, BytesMut};
|
||||||
use http::header::{self, HeaderName, HeaderValue};
|
use http::header::{self, HeaderName, HeaderValue};
|
||||||
use http::{Error as HttpError, Method, Uri, Version};
|
use http::{Error as HttpError, Method, Uri, Version};
|
||||||
use percent_encoding::percent_encode;
|
|
||||||
|
|
||||||
use crate::cookie::{Cookie, CookieJar, USERINFO};
|
use crate::cookie::{Cookie, CookieJar};
|
||||||
use crate::header::HeaderMap;
|
use crate::header::HeaderMap;
|
||||||
use crate::header::{Header, IntoHeaderValue};
|
use crate::header::{Header, IntoHeaderValue};
|
||||||
use crate::payload::Payload;
|
use crate::payload::Payload;
|
||||||
|
@ -165,9 +164,9 @@ impl TestRequest {
|
||||||
|
|
||||||
let mut cookie = String::new();
|
let mut cookie = String::new();
|
||||||
for c in inner.cookies.delta() {
|
for c in inner.cookies.delta() {
|
||||||
let name = percent_encode(c.name().as_bytes(), USERINFO);
|
// ensure only name=value is written to cookie header
|
||||||
let value = percent_encode(c.value().as_bytes(), USERINFO);
|
let c = Cookie::new(c.name(), c.value());
|
||||||
let _ = write!(&mut cookie, "; {}={}", name, value);
|
let _ = write!(&mut cookie, "; {}", c.encoded());
|
||||||
}
|
}
|
||||||
if !cookie.is_empty() {
|
if !cookie.is_empty() {
|
||||||
head.headers.insert(
|
head.headers.insert(
|
||||||
|
|
|
@ -6,11 +6,10 @@ use std::{fmt, net};
|
||||||
|
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures_core::Stream;
|
use futures_core::Stream;
|
||||||
use percent_encoding::percent_encode;
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use actix_http::body::Body;
|
use actix_http::body::Body;
|
||||||
use actix_http::cookie::{Cookie, CookieJar, USERINFO};
|
use actix_http::cookie::{Cookie, CookieJar};
|
||||||
use actix_http::http::header::{self, Header, IntoHeaderValue};
|
use actix_http::http::header::{self, Header, IntoHeaderValue};
|
||||||
use actix_http::http::{
|
use actix_http::http::{
|
||||||
uri, ConnectionType, Error as HttpError, HeaderMap, HeaderName, HeaderValue, Method,
|
uri, ConnectionType, Error as HttpError, HeaderMap, HeaderName, HeaderValue, Method,
|
||||||
|
@ -529,9 +528,9 @@ impl ClientRequest {
|
||||||
if let Some(ref mut jar) = self.cookies {
|
if let Some(ref mut jar) = self.cookies {
|
||||||
let mut cookie = String::new();
|
let mut cookie = String::new();
|
||||||
for c in jar.delta() {
|
for c in jar.delta() {
|
||||||
let name = percent_encode(c.name().as_bytes(), USERINFO);
|
// ensure only name=value is written to cookie header
|
||||||
let value = percent_encode(c.value().as_bytes(), USERINFO);
|
let c = Cookie::new(c.name(), c.value());
|
||||||
let _ = write!(&mut cookie, "; {}={}", name, value);
|
let _ = write!(&mut cookie, "; {}", c.encoded());
|
||||||
}
|
}
|
||||||
self.head.headers.insert(
|
self.head.headers.insert(
|
||||||
header::COOKIE,
|
header::COOKIE,
|
||||||
|
|
|
@ -2,12 +2,11 @@
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::fmt::Write as FmtWrite;
|
use std::fmt::Write as FmtWrite;
|
||||||
|
|
||||||
use actix_http::cookie::{Cookie, CookieJar, USERINFO};
|
use actix_http::cookie::{Cookie, CookieJar};
|
||||||
use actix_http::http::header::{self, Header, HeaderValue, IntoHeaderValue};
|
use actix_http::http::header::{self, Header, HeaderValue, IntoHeaderValue};
|
||||||
use actix_http::http::{Error as HttpError, HeaderName, StatusCode, Version};
|
use actix_http::http::{Error as HttpError, HeaderName, StatusCode, Version};
|
||||||
use actix_http::{h1, Payload, ResponseHead};
|
use actix_http::{h1, Payload, ResponseHead};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use percent_encoding::percent_encode;
|
|
||||||
|
|
||||||
use crate::ClientResponse;
|
use crate::ClientResponse;
|
||||||
|
|
||||||
|
@ -90,9 +89,8 @@ impl TestResponse {
|
||||||
|
|
||||||
let mut cookie = String::new();
|
let mut cookie = String::new();
|
||||||
for c in self.cookies.delta() {
|
for c in self.cookies.delta() {
|
||||||
let name = percent_encode(c.name().as_bytes(), USERINFO);
|
let c = Cookie::new(c.name(), c.value());
|
||||||
let value = percent_encode(c.value().as_bytes(), USERINFO);
|
let _ = write!(&mut cookie, "; {}", c.encoded());
|
||||||
let _ = write!(&mut cookie, "; {}={}", name, value);
|
|
||||||
}
|
}
|
||||||
if !cookie.is_empty() {
|
if !cookie.is_empty() {
|
||||||
head.headers.insert(
|
head.headers.insert(
|
||||||
|
|
|
@ -9,9 +9,7 @@ use actix_codec::Framed;
|
||||||
use actix_http::cookie::{Cookie, CookieJar};
|
use actix_http::cookie::{Cookie, CookieJar};
|
||||||
use actix_http::{ws, Payload, RequestHead};
|
use actix_http::{ws, Payload, RequestHead};
|
||||||
use actix_rt::time::timeout;
|
use actix_rt::time::timeout;
|
||||||
use percent_encoding::percent_encode;
|
|
||||||
|
|
||||||
use actix_http::cookie::USERINFO;
|
|
||||||
pub use actix_http::ws::{CloseCode, CloseReason, Codec, Frame, Message};
|
pub use actix_http::ws::{CloseCode, CloseReason, Codec, Frame, Message};
|
||||||
|
|
||||||
use crate::connect::BoxedSocket;
|
use crate::connect::BoxedSocket;
|
||||||
|
@ -248,9 +246,9 @@ impl WebsocketsRequest {
|
||||||
if let Some(ref mut jar) = self.cookies {
|
if let Some(ref mut jar) = self.cookies {
|
||||||
let mut cookie = String::new();
|
let mut cookie = String::new();
|
||||||
for c in jar.delta() {
|
for c in jar.delta() {
|
||||||
let name = percent_encode(c.name().as_bytes(), USERINFO);
|
// ensure only name=value is written to cookie header
|
||||||
let value = percent_encode(c.value().as_bytes(), USERINFO);
|
let c = Cookie::new(c.name(), c.value());
|
||||||
let _ = write!(&mut cookie, "; {}={}", name, value);
|
let _ = write!(&mut cookie, "; {}", c.encoded());
|
||||||
}
|
}
|
||||||
self.head.headers.insert(
|
self.head.headers.insert(
|
||||||
header::COOKIE,
|
header::COOKIE,
|
||||||
|
|
Loading…
Reference in New Issue