1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-05-19 16:58:14 +00:00

Merge branch 'master' into scope_work

This commit is contained in:
Jon Lim 2024-03-31 20:44:36 -07:00
commit 455c064728
59 changed files with 226 additions and 126 deletions

View file

@ -45,7 +45,7 @@ jobs:
toolchain: ${{ matrix.version.version }}
- name: Install cargo-hack and cargo-ci-cache-clean
uses: taiki-e/install-action@v2.26.12
uses: taiki-e/install-action@v2.32.0
with:
tool: cargo-hack,cargo-ci-cache-clean
@ -81,11 +81,14 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Free Disk Space
run: ./scripts/free-disk-space.sh
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
- name: Install cargo-hack
uses: taiki-e/install-action@v2.26.12
uses: taiki-e/install-action@v2.32.0
with:
tool: cargo-hack
@ -106,7 +109,7 @@ jobs:
uses: actions-rust-lang/setup-rust-toolchain@v1.8.0
- name: Install nextest
uses: taiki-e/install-action@v2.26.12
uses: taiki-e/install-action@v2.32.0
with:
tool: nextest

View file

@ -50,7 +50,7 @@ jobs:
toolchain: ${{ matrix.version.version }}
- name: Install cargo-hack and cargo-ci-cache-clean
uses: taiki-e/install-action@v2.26.12
uses: taiki-e/install-action@v2.32.0
with:
tool: cargo-hack,cargo-ci-cache-clean
@ -70,6 +70,7 @@ jobs:
shell: bash
run: |
set -e
cargo test --lib --tests -p=actix-router --no-default-features
cargo test --lib --tests -p=actix-router --all-features
cargo test --lib --tests -p=actix-http --all-features
cargo test --lib --tests -p=actix-web --features=rustls-0_20,rustls-0_21,rustls-0_22,openssl -- --skip=test_reading_deflate_encoding_large_random_rustls

View file

@ -23,7 +23,7 @@ jobs:
components: llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@v2.26.12
uses: taiki-e/install-action@v2.32.0
with:
tool: cargo-llvm-cov
@ -31,7 +31,7 @@ jobs:
run: cargo llvm-cov --workspace --all-features --codecov --output-path codecov.json
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4.0.1
uses: codecov/codecov-action@v4.1.1
with:
files: codecov.json
fail_ci_if_error: true

View file

@ -82,7 +82,7 @@ jobs:
toolchain: nightly-2023-08-25
- name: Install cargo-public-api
uses: taiki-e/install-action@v2.26.12
uses: taiki-e/install-action@v2.32.0
with:
tool: cargo-public-api

View file

@ -47,5 +47,5 @@ actix-server = { version = "2.2", optional = true } # ensure matching tokio-urin
actix-rt = "2.7"
actix-test = "0.1"
actix-web = "4"
env_logger = "0.10"
env_logger = "0.11"
tempfile = "3.2"

View file

@ -75,7 +75,7 @@ mod tests {
dev::ServiceFactory,
guard,
http::{
header::{self, ContentDisposition, DispositionParam, DispositionType},
header::{self, ContentDisposition, DispositionParam},
Method, StatusCode,
},
middleware::Compress,

View file

@ -106,7 +106,7 @@ h2 = { version = "0.3.24", optional = true }
# websockets
local-channel = { version = "0.1", optional = true }
base64 = { version = "0.21", optional = true }
base64 = { version = "0.22", optional = true }
rand = { version = "0.8", optional = true }
sha1 = { version = "0.10", optional = true }
@ -127,7 +127,7 @@ actix-web = "4"
async-stream = "0.3"
criterion = { version = "0.5", features = ["html_reports"] }
divan = "0.1.8"
env_logger = "0.10"
env_logger = "0.11"
futures-util = { version = "0.3.17", default-features = false, features = ["alloc"] }
memchr = "2.4"
once_cell = "1.9"

View file

@ -531,7 +531,6 @@ where
mod tests {
use actix_rt::pin;
use actix_utils::future::poll_fn;
use bytes::{Bytes, BytesMut};
use futures_util::stream;
use super::*;

View file

@ -399,9 +399,7 @@ pub enum ContentTypeError {
#[cfg(test)]
mod tests {
use std::io;
use http::{Error as HttpError, StatusCode};
use http::Error as HttpError;
use super::*;

View file

@ -198,9 +198,6 @@ impl Encoder<Message<(Response<()>, BodySize)>> for Codec {
#[cfg(test)]
mod tests {
use bytes::BytesMut;
use http::Method;
use super::*;
use crate::HttpMessage as _;

View file

@ -563,15 +563,8 @@ impl Decoder for PayloadDecoder {
#[cfg(test)]
mod tests {
use bytes::{Bytes, BytesMut};
use http::{Method, Version};
use super::*;
use crate::{
error::ParseError,
header::{HeaderName, SET_COOKIE},
HttpMessage as _,
};
use crate::{header::SET_COOKIE, HttpMessage as _};
impl PayloadType {
pub(crate) fn unwrap(self) -> PayloadDecoder {

View file

@ -221,7 +221,7 @@ pub fn handshake_response(req: &RequestHead) -> ResponseBuilder {
#[cfg(test)]
mod tests {
use super::*;
use crate::{header, test::TestRequest, Method};
use crate::{header, test::TestRequest};
#[test]
fn test_handshake() {

View file

@ -1,7 +1,4 @@
use std::{
convert::{From, Into},
fmt,
};
use std::fmt;
use base64::prelude::*;
use tracing::error;

View file

@ -863,7 +863,7 @@ mod tests {
test::TestRequest,
FromRequest,
};
use bytes::{BufMut as _, Bytes};
use bytes::BufMut as _;
use futures_util::{future::lazy, StreamExt as _};
use tokio::sync::mpsc;
use tokio_stream::wrappers::UnboundedReceiverStream;

View file

@ -2,6 +2,7 @@
## Unreleased
- Add `unicode` crate feature (on-by-default) to switch between `regex` and `regex-lite` as a trade-off between full unicode support and binary size.
- Minimum supported Rust version (MSRV) is now 1.72.
## 0.5.2

View file

@ -17,12 +17,16 @@ name = "actix_router"
path = "src/lib.rs"
[features]
default = ["http"]
default = ["http", "unicode"]
http = ["dep:http"]
unicode = ["dep:regex"]
[dependencies]
bytestring = ">=0.1.5, <2"
cfg-if = "1"
http = { version = "0.2.7", optional = true }
regex = "1.5"
regex = { version = "1.5", optional = true }
regex-lite = "0.1"
serde = "1"
tracing = { version = "0.1.30", default-features = false, features = ["log"] }
@ -35,6 +39,7 @@ percent-encoding = "2.1"
[[bench]]
name = "router"
harness = false
required-features = ["unicode"]
[[bench]]
name = "quoter"

View file

@ -500,10 +500,10 @@ impl<'de> de::VariantAccess<'de> for UnitVariant {
#[cfg(test)]
mod tests {
use serde::{de, Deserialize};
use serde::Deserialize;
use super::*;
use crate::{path::Path, router::Router, ResourceDef};
use crate::{router::Router, ResourceDef};
#[derive(Deserialize)]
struct MyStruct {

View file

@ -10,6 +10,7 @@ mod de;
mod path;
mod pattern;
mod quoter;
mod regex_set;
mod resource;
mod resource_path;
mod router;

View file

@ -0,0 +1,66 @@
//! Abstraction over `regex` and `regex-lite` depending on whether we have `unicode` crate feature
//! enabled.
use cfg_if::cfg_if;
#[cfg(feature = "unicode")]
pub(crate) use regex::{escape, Regex};
#[cfg(not(feature = "unicode"))]
pub(crate) use regex_lite::{escape, Regex};
#[cfg(feature = "unicode")]
#[derive(Debug, Clone)]
pub(crate) struct RegexSet(regex::RegexSet);
#[cfg(not(feature = "unicode"))]
#[derive(Debug, Clone)]
pub(crate) struct RegexSet(Vec<regex_lite::Regex>);
impl RegexSet {
/// Create a new regex set.
///
/// # Panics
///
/// Panics if any path patterns are malformed.
pub(crate) fn new(re_set: Vec<String>) -> Self {
cfg_if! {
if #[cfg(feature = "unicode")] {
Self(regex::RegexSet::new(re_set).unwrap())
} else {
Self(re_set.iter().map(|re| Regex::new(re).unwrap()).collect())
}
}
}
/// Create a new empty regex set.
pub(crate) fn empty() -> Self {
cfg_if! {
if #[cfg(feature = "unicode")] {
Self(regex::RegexSet::empty())
} else {
Self(Vec::new())
}
}
}
/// Returns true if regex set matches `path`.
pub(crate) fn is_match(&self, path: &str) -> bool {
cfg_if! {
if #[cfg(feature = "unicode")] {
self.0.is_match(path)
} else {
self.0.iter().any(|re| re.is_match(path))
}
}
}
/// Returns index within `path` of first match.
pub(crate) fn first_match_idx(&self, path: &str) -> Option<usize> {
cfg_if! {
if #[cfg(feature = "unicode")] {
self.0.matches(path).into_iter().next()
} else {
Some(self.0.iter().enumerate().find(|(_, re)| re.is_match(path))?.0)
}
}
}
}

View file

@ -5,10 +5,13 @@ use std::{
mem,
};
use regex::{escape, Regex, RegexSet};
use tracing::error;
use crate::{path::PathItem, IntoPatterns, Patterns, Resource, ResourcePath};
use crate::{
path::PathItem,
regex_set::{escape, Regex, RegexSet},
IntoPatterns, Patterns, Resource, ResourcePath,
};
const MAX_DYNAMIC_SEGMENTS: usize = 16;
@ -233,7 +236,7 @@ enum PatternSegment {
Var(String),
}
#[derive(Clone, Debug)]
#[derive(Debug, Clone)]
#[allow(clippy::large_enum_variant)]
enum PatternType {
/// Single constant/literal segment.
@ -603,7 +606,7 @@ impl ResourceDef {
PatternType::Dynamic(re, _) => Some(re.captures(path)?[1].len()),
PatternType::DynamicSet(re, params) => {
let idx = re.matches(path).into_iter().next()?;
let idx = re.first_match_idx(path)?;
let (ref pattern, _) = params[idx];
Some(pattern.captures(path)?[1].len())
}
@ -706,7 +709,7 @@ impl ResourceDef {
PatternType::DynamicSet(re, params) => {
let path = path.unprocessed();
let (pattern, names) = match re.matches(path).into_iter().next() {
let (pattern, names) = match re.first_match_idx(path) {
Some(idx) => &params[idx],
_ => return false,
};
@ -870,7 +873,7 @@ impl ResourceDef {
}
}
let pattern_re_set = RegexSet::new(re_set).unwrap();
let pattern_re_set = RegexSet::new(re_set);
let segments = segments.unwrap_or_default();
(

View file

@ -32,6 +32,6 @@ actix-test = "0.1"
awc = { version = "3", default-features = false }
actix-web = { version = "4", features = ["macros"] }
env_logger = "0.10"
env_logger = "0.11"
futures-util = { version = "0.3.17", default-features = false, features = ["std"] }
mime = "0.3"

View file

@ -248,13 +248,11 @@ where
mod tests {
use std::time::Duration;
use actix::Actor;
use actix_web::{
http::StatusCode,
test::{call_service, init_service, read_body, TestRequest},
web, App, HttpResponse,
};
use bytes::Bytes;
use super::*;

View file

@ -817,10 +817,7 @@ where
#[cfg(test)]
mod tests {
use actix_web::{
http::{header, Method},
test::TestRequest,
};
use actix_web::test::TestRequest;
use super::*;

View file

@ -2,6 +2,10 @@
## Unreleased
### Added
- Add `unicode` crate feature (on-by-default) to switch between `regex` and `regex-lite` as a trade-off between full unicode support and binary size.
### Changed
- Minimum supported Rust version (MSRV) is now 1.72.

View file

@ -40,7 +40,7 @@ name = "actix_web"
path = "src/lib.rs"
[features]
default = ["macros", "compress-brotli", "compress-gzip", "compress-zstd", "cookies", "http2"]
default = ["macros", "compress-brotli", "compress-gzip", "compress-zstd", "cookies", "http2", "unicode"]
# Brotli algorithm content-encoding support
compress-brotli = ["actix-http/compress-brotli", "__compress"]
@ -72,6 +72,9 @@ rustls-0_21 = ["http2", "actix-http/rustls-0_21", "actix-tls/accept", "actix-tls
# TLS via Rustls v0.22
rustls-0_22 = ["http2", "actix-http/rustls-0_22", "actix-tls/accept", "actix-tls/rustls-0_22"]
# Full unicode support
unicode = ["dep:regex", "actix-router/unicode"]
# Internal (PRIVATE!) features used to aid testing and checking feature status.
# Don't rely on these whatsoever. They may disappear at anytime.
__compress = []
@ -89,7 +92,7 @@ actix-utils = "3"
actix-tls = { version = "3.3", default-features = false, optional = true }
actix-http = { version = "3.6", features = ["ws"] }
actix-router = "0.5"
actix-router = { version = "0.5", default-features = false, features = ["http"] }
actix-web-codegen = { version = "4.2", optional = true }
ahash = "0.8"
@ -107,7 +110,8 @@ log = "0.4"
mime = "0.3"
once_cell = "1.5"
pin-project-lite = "0.2.7"
regex = "1.5.5"
regex = { version = "1.5.5", optional = true }
regex-lite = "0.1"
serde = "1.0"
serde_json = "1.0"
serde_urlencoded = "0.7"
@ -124,7 +128,7 @@ awc = { version = "3", features = ["openssl"] }
brotli = "3.3.3"
const-str = "0.5"
criterion = { version = "0.5", features = ["html_reports"] }
env_logger = "0.10"
env_logger = "0.11"
flate2 = "1.0.13"
futures-util = { version = "0.3.17", default-features = false, features = ["std"] }
rand = "0.8"

View file

@ -471,7 +471,6 @@ mod tests {
Method, StatusCode,
},
middleware::DefaultHeaders,
service::ServiceRequest,
test::{call_service, init_service, read_body, try_init_service, TestRequest},
web, HttpRequest, HttpResponse,
};

View file

@ -380,7 +380,7 @@ impl Guard for HeaderGuard {
#[cfg(test)]
mod tests {
use actix_http::{header, Method};
use actix_http::Method;
use super::*;
use crate::test::TestRequest;

View file

@ -13,7 +13,10 @@
use std::fmt::{self, Write};
use once_cell::sync::Lazy;
#[cfg(feature = "unicode")]
use regex::Regex;
#[cfg(not(feature = "unicode"))]
use regex_lite::Regex;
use super::{ExtendedValue, Header, TryIntoHeaderValue, Writer};
use crate::http::header;

View file

@ -126,7 +126,7 @@ mod tests {
use std::fmt;
use super::*;
use crate::{http::header::Header, test::TestRequest, HttpRequest};
use crate::{test::TestRequest, HttpRequest};
fn req_from_raw_headers<H: Header, I: IntoIterator<Item = V>, V: AsRef<[u8]>>(
header_lines: I,

View file

@ -33,7 +33,7 @@ use crate::{
/// considered in this selection process.
///
/// # Pre-compressed Payload
/// If you are serving some data is already using a compressed representation (e.g., a gzip
/// If you are serving some data that is already using a compressed representation (e.g., a gzip
/// compressed HTML file from disk) you can signal this to `Compress` by setting an appropriate
/// `Content-Encoding` header. In addition to preventing double compressing the payload, this header
/// is required by the spec when using compressed representations and will inform the client that

View file

@ -135,7 +135,7 @@ mod tests {
use super::*;
use crate::{
body::BoxBody,
dev::{ServiceRequest, ServiceResponse},
dev::ServiceRequest,
error::Result,
http::{
header::{HeaderValue, CONTENT_TYPE},

View file

@ -190,8 +190,6 @@ mod tests {
use super::*;
use crate::{
dev::ServiceRequest,
http::header::CONTENT_TYPE,
test::{self, TestRequest},
HttpResponse,
};

View file

@ -407,10 +407,7 @@ mod tests {
use super::*;
use crate::{
body,
http::{
header::{HeaderValue, CONTENT_TYPE},
StatusCode,
},
http::header::{HeaderValue, CONTENT_TYPE},
test::{self, TestRequest},
};

View file

@ -18,7 +18,10 @@ use bytes::Bytes;
use futures_core::ready;
use log::{debug, warn};
use pin_project_lite::pin_project;
use regex::{Regex, RegexSet};
#[cfg(feature = "unicode")]
use regex::Regex;
#[cfg(not(feature = "unicode"))]
use regex_lite::Regex;
use time::{format_description::well_known::Rfc3339, OffsetDateTime};
use crate::{
@ -87,7 +90,7 @@ pub struct Logger(Rc<Inner>);
struct Inner {
format: Format,
exclude: HashSet<String>,
exclude_regex: RegexSet,
exclude_regex: Vec<Regex>,
log_target: Cow<'static, str>,
}
@ -97,7 +100,7 @@ impl Logger {
Logger(Rc::new(Inner {
format: Format::new(format),
exclude: HashSet::new(),
exclude_regex: RegexSet::empty(),
exclude_regex: Vec::new(),
log_target: Cow::Borrowed(module_path!()),
}))
}
@ -114,10 +117,7 @@ impl Logger {
/// Ignore and do not log access info for paths that match regex.
pub fn exclude_regex<T: Into<String>>(mut self, path: T) -> Self {
let inner = Rc::get_mut(&mut self.0).unwrap();
let mut patterns = inner.exclude_regex.patterns().to_vec();
patterns.push(path.into());
let regex_set = RegexSet::new(patterns).unwrap();
inner.exclude_regex = regex_set;
inner.exclude_regex.push(Regex::new(&path.into()).unwrap());
self
}
@ -240,7 +240,7 @@ impl Default for Logger {
Logger(Rc::new(Inner {
format: Format::default(),
exclude: HashSet::new(),
exclude_regex: RegexSet::empty(),
exclude_regex: Vec::new(),
log_target: Cow::Borrowed(module_path!()),
}))
}
@ -300,7 +300,11 @@ where
fn call(&self, req: ServiceRequest) -> Self::Future {
let excluded = self.inner.exclude.contains(req.path())
|| self.inner.exclude_regex.is_match(req.path());
|| self
.inner
.exclude_regex
.iter()
.any(|r| r.is_match(req.path()));
if excluded {
LoggerResponse {
@ -716,7 +720,7 @@ impl<'a> fmt::Display for FormatDisplay<'a> {
#[cfg(test)]
mod tests {
use actix_service::{IntoService, Service, Transform};
use actix_service::IntoService;
use actix_utils::future::ok;
use super::*;

View file

@ -4,7 +4,10 @@ use actix_http::uri::{PathAndQuery, Uri};
use actix_service::{Service, Transform};
use actix_utils::future::{ready, Ready};
use bytes::Bytes;
#[cfg(feature = "unicode")]
use regex::Regex;
#[cfg(not(feature = "unicode"))]
use regex_lite::Regex;
use crate::{
service::{ServiceRequest, ServiceResponse},
@ -205,7 +208,6 @@ mod tests {
use super::*;
use crate::{
dev::ServiceRequest,
guard::fn_guard,
test::{call_service, init_service, TestRequest},
web, App, HttpResponse,

View file

@ -182,7 +182,7 @@ impl Responder for Redirect {
#[cfg(test)]
mod tests {
use super::*;
use crate::{dev::Service, http::StatusCode, test, App};
use crate::{dev::Service, test, App};
#[actix_rt::test]
async fn absolute_redirects() {

View file

@ -523,7 +523,7 @@ mod tests {
use super::*;
use crate::{
dev::{ResourceDef, ResourceMap, Service},
dev::{ResourceDef, Service},
http::{header, StatusCode},
test::{self, call_service, init_service, read_body, TestRequest},
web, App, HttpResponse,

View file

@ -540,20 +540,14 @@ mod tests {
use std::time::Duration;
use actix_rt::time::sleep;
use actix_service::Service;
use actix_utils::future::ok;
use super::*;
use crate::{
guard,
http::{
header::{self, HeaderValue},
Method, StatusCode,
},
http::{header::HeaderValue, Method, StatusCode},
middleware::DefaultHeaders,
service::{ServiceRequest, ServiceResponse},
test::{call_service, init_service, TestRequest},
web, App, Error, HttpMessage, HttpResponse,
App, HttpMessage,
};
#[test]

View file

@ -408,10 +408,7 @@ mod tests {
use super::*;
use crate::{
body,
http::{
header::{self, HeaderValue, CONTENT_TYPE},
StatusCode,
},
http::header::{HeaderValue, CONTENT_TYPE},
test::assert_body_eq,
};

View file

@ -175,10 +175,7 @@ mod tests {
use super::*;
use crate::{
http::{
header::{HeaderValue, CONTENT_TYPE},
StatusCode,
},
http::header::{HeaderValue, CONTENT_TYPE},
test::TestRequest,
};

View file

@ -188,15 +188,11 @@ impl_into_string_responder!(Cow<'_, str>);
pub(crate) mod tests {
use actix_http::body::to_bytes;
use actix_service::Service;
use bytes::{Bytes, BytesMut};
use super::*;
use crate::{
error,
http::{
header::{HeaderValue, CONTENT_TYPE},
StatusCode,
},
http::header::{HeaderValue, CONTENT_TYPE},
test::{assert_body_eq, init_service, TestRequest},
web, App,
};

View file

@ -399,7 +399,7 @@ mod tests {
use static_assertions::assert_impl_all;
use super::*;
use crate::http::header::{HeaderValue, COOKIE};
use crate::http::header::COOKIE;
assert_impl_all!(HttpResponse: Responder);
assert_impl_all!(HttpResponse<String>: Responder);

View file

@ -92,6 +92,7 @@ pub struct RouteService {
}
impl RouteService {
// TODO(breaking): remove pass by ref mut
#[allow(clippy::needless_pass_by_ref_mut)]
pub fn check(&self, req: &mut ServiceRequest) -> bool {
let guard_ctx = req.guard_ctx();

View file

@ -547,7 +547,6 @@ impl ServiceFactory<ServiceRequest> for ScopeEndpoint {
#[cfg(test)]
mod tests {
use actix_service::Service;
use actix_utils::future::ok;
use bytes::Bytes;
@ -559,7 +558,6 @@ mod tests {
Method, StatusCode,
},
middleware::DefaultHeaders,
service::{ServiceRequest, ServiceResponse},
test::{assert_body_eq, call_service, init_service, read_body, TestRequest},
web, App, HttpMessage, HttpRequest, HttpResponse,
};

View file

@ -700,7 +700,7 @@ mod tests {
use crate::{
guard, http,
test::{self, init_service, TestRequest},
web, App, HttpResponse,
web, App,
};
#[actix_rt::test]

View file

@ -350,7 +350,7 @@ mod tests {
use std::time::SystemTime;
use super::*;
use crate::{http::header, test::init_service, web, App, Error, HttpResponse, Responder};
use crate::{http::header, test::init_service, web, App, Error, Responder};
#[actix_rt::test]
async fn test_basics() {

View file

@ -287,10 +287,7 @@ mod tests {
use serde::{Deserialize, Serialize};
use super::*;
use crate::{
test::TestRequest,
web::{Form, Json},
};
use crate::test::TestRequest;
#[derive(Debug, Clone, Serialize, Deserialize)]
struct TestForm {

View file

@ -418,7 +418,7 @@ mod tests {
use super::*;
use crate::{
http::{
header::{HeaderValue, CONTENT_LENGTH, CONTENT_TYPE},
header::{HeaderValue, CONTENT_TYPE},
StatusCode,
},
test::{assert_body_eq, TestRequest},

View file

@ -440,13 +440,11 @@ impl Future for HttpMessageBody {
#[cfg(test)]
mod tests {
use bytes::Bytes;
use super::*;
use crate::{
http::{header, StatusCode},
http::StatusCode,
test::{call_service, init_service, read_body, TestRequest},
web, App, Responder,
App, Responder,
};
#[actix_rt::test]

View file

@ -79,7 +79,7 @@ actix-rt = { version = "2.1", default-features = false }
actix-tls = { version = "3.3", features = ["connect", "uri"] }
actix-utils = "3"
base64 = "0.21"
base64 = "0.22"
bytes = "1"
cfg-if = "1"
derive_more = "0.99.5"
@ -118,7 +118,7 @@ actix-web = { version = "4", features = ["openssl"] }
brotli = "3.3.3"
const-str = "0.5"
env_logger = "0.10"
env_logger = "0.11"
flate2 = "1.0.13"
futures-util = { version = "0.3.17", default-features = false }
static_assertions = "1.1"

View file

@ -380,8 +380,6 @@ mod test {
use std::{
future::Future,
net,
pin::Pin,
task::{Context, Poll},
time::{Duration, Instant},
};

View file

@ -401,6 +401,7 @@ where
use actix_tls::connect::Connection;
use actix_utils::future::{ready, Ready};
#[allow(non_local_definitions)]
impl IntoConnectionIo for TcpConnection<Uri, Box<dyn ConnectionIo>> {
fn into_connection_io(self) -> (Box<dyn ConnectionIo>, Protocol) {
let io = self.into_parts().0;
@ -451,6 +452,7 @@ where
use actix_tls::connect::openssl::{reexports::AsyncSslStream, TlsConnector};
#[allow(non_local_definitions)]
impl<IO: ConnectionIo> IntoConnectionIo for TcpConnection<Uri, AsyncSslStream<IO>> {
fn into_connection_io(self) -> (Box<dyn ConnectionIo>, Protocol) {
let sock = self.into_parts().0;
@ -488,6 +490,7 @@ where
use actix_tls::connect::rustls_0_20::{reexports::AsyncTlsStream, TlsConnector};
#[allow(non_local_definitions)]
impl<Io: ConnectionIo> IntoConnectionIo for TcpConnection<Uri, AsyncTlsStream<Io>> {
fn into_connection_io(self) -> (Box<dyn ConnectionIo>, Protocol) {
let sock = self.into_parts().0;
@ -521,6 +524,7 @@ where
use actix_tls::connect::rustls_0_21::{reexports::AsyncTlsStream, TlsConnector};
#[allow(non_local_definitions)]
impl<Io: ConnectionIo> IntoConnectionIo for TcpConnection<Uri, AsyncTlsStream<Io>> {
fn into_connection_io(self) -> (Box<dyn ConnectionIo>, Protocol) {
let sock = self.into_parts().0;
@ -557,6 +561,7 @@ where
use actix_tls::connect::rustls_0_22::{reexports::AsyncTlsStream, TlsConnector};
#[allow(non_local_definitions)]
impl<Io: ConnectionIo> IntoConnectionIo for TcpConnection<Uri, AsyncTlsStream<Io>> {
fn into_connection_io(self) -> (Box<dyn ConnectionIo>, Protocol) {
let sock = self.into_parts().0;
@ -935,7 +940,6 @@ mod resolver {
use std::{cell::RefCell, net::SocketAddr};
use actix_tls::connect::Resolve;
use futures_core::future::LocalBoxFuture;
use trust_dns_resolver::{
config::{ResolverConfig, ResolverOpts},
system_conf::read_system_conf,

View file

@ -374,12 +374,11 @@ impl<Io: ConnectionIo> Acquired<Io> {
#[cfg(test)]
mod test {
use std::{cell::Cell, io};
use std::cell::Cell;
use http::Uri;
use super::*;
use crate::client::connection::ConnectionType;
/// A stream type that always returns pending on async read.
///

View file

@ -102,6 +102,7 @@
#![deny(rust_2018_idioms, nonstandard_style)]
#![warn(future_incompatible)]
#![allow(unknown_lints)] // temp: #[allow(non_local_definitions)]
#![allow(
clippy::type_complexity,
clippy::borrow_interior_mutable_const,

View file

@ -303,10 +303,7 @@ mod tests {
use actix_web::{web, App, Error, HttpRequest, HttpResponse};
use super::*;
use crate::{
http::{header::HeaderValue, StatusCode},
ClientBuilder,
};
use crate::{http::header::HeaderValue, ClientBuilder};
#[actix_rt::test]
async fn basic_redirect() {

View file

@ -118,7 +118,7 @@ mod tests {
use static_assertions::assert_impl_all;
use super::*;
use crate::{http::header, test::TestResponse};
use crate::test::TestResponse;
assert_impl_all!(JsonBody<BoxedPayloadStream, String>: Unpin);

View file

@ -110,7 +110,7 @@ mod tests {
use static_assertions::assert_impl_all;
use super::*;
use crate::{http::header, test::TestResponse};
use crate::test::TestResponse;
assert_impl_all!(ResponseBody<()>: Unpin);

View file

@ -103,7 +103,7 @@ mod tests {
use actix_http::header::HttpDate;
use super::*;
use crate::{cookie, http::header};
use crate::http::header;
#[test]
fn test_basics() {

53
scripts/free-disk-space.sh Executable file
View file

@ -0,0 +1,53 @@
#!/usr/bin/env bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# The Azure provided machines typically have the following disk allocation:
# Total space: 85GB
# Allocated: 67 GB
# Free: 17 GB
# This script frees up 28 GB of disk space by deleting unneeded packages and
# large directories.
# The Flink end to end tests download and generate more than 17 GB of files,
# causing unpredictable behavior and build failures.
echo "=============================================================================="
echo "Freeing up disk space on CI system"
echo "=============================================================================="
echo "Listing 100 largest packages"
dpkg-query -Wf '${Installed-Size}\t${Package}\n' | sort -n | tail -n 100
df -h
echo "Removing large packages"
sudo apt-get remove -y '^dotnet-.*'
sudo apt-get remove -y 'php.*'
sudo apt-get remove -y '^mongodb-.*'
sudo apt-get remove -y '^mysql-.*'
sudo apt-get remove -y azure-cli google-cloud-sdk hhvm google-chrome-stable firefox powershell mono-devel libgl1-mesa-dri
sudo apt-get autoremove -y
sudo apt-get clean
df -h
echo "Removing large directories"
sudo rm -rf /usr/share/dotnet/
sudo rm -rf /usr/local/graalvm/
sudo rm -rf /usr/local/.ghcup/
sudo rm -rf /usr/local/share/powershell
sudo rm -rf /usr/local/share/chromium
sudo rm -rf /usr/local/lib/android
sudo rm -rf /usr/local/lib/node_modules
df -h