mirror of
https://github.com/fafhrd91/actix-web
synced 2025-07-18 23:45:41 +02:00
Compare commits
11 Commits
http-v0.2.
...
web-v1.0.7
Author | SHA1 | Date | |
---|---|---|---|
|
bae29897d6 | ||
|
616981ecf9 | ||
|
98bf8ab098 | ||
|
c193137905 | ||
|
a07cdd6533 | ||
|
61e492e7e3 | ||
|
23d768a77b | ||
|
87b7162473 | ||
|
979c4d44f4 | ||
|
5d248cad89 | ||
|
b1cb72d088 |
20
CHANGES.md
20
CHANGES.md
@@ -1,6 +1,13 @@
|
||||
# Changes
|
||||
|
||||
## [1.0.6] - 2019-xx-xx
|
||||
## [1.0.7] - 2019-08-29
|
||||
|
||||
### Fixed
|
||||
|
||||
* Request Extensions leak #1062
|
||||
|
||||
|
||||
## [1.0.6] - 2019-08-28
|
||||
|
||||
### Added
|
||||
|
||||
@@ -8,11 +15,20 @@
|
||||
|
||||
* Form immplements Responder, returning a `application/x-www-form-urlencoded` response
|
||||
|
||||
* Add `into_inner` to `Data`
|
||||
|
||||
* Add `test::TestRequest::set_form()` convenience method to automatically serialize data and set
|
||||
the header in test requests.
|
||||
|
||||
### Changed
|
||||
|
||||
* `Query` payload made `pub`. Allows user to pattern-match the payload.
|
||||
|
||||
* Update serde_urlencoded to "0.6.1"
|
||||
* Enable `rust-tls` feature for client #1045
|
||||
|
||||
* Update serde_urlencoded to 0.6.1
|
||||
|
||||
* Update url to 2.1
|
||||
|
||||
|
||||
## [1.0.5] - 2019-07-18
|
||||
|
10
Cargo.toml
10
Cargo.toml
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "actix-web"
|
||||
version = "1.0.5"
|
||||
version = "1.0.7"
|
||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
description = "Actix web is a simple, pragmatic and extremely fast web framework for Rust."
|
||||
readme = "README.md"
|
||||
@@ -66,7 +66,7 @@ fail = ["actix-http/fail"]
|
||||
ssl = ["openssl", "actix-server/ssl", "awc/ssl"]
|
||||
|
||||
# rustls
|
||||
rust-tls = ["rustls", "actix-server/rust-tls"]
|
||||
rust-tls = ["rustls", "actix-server/rust-tls", "awc/rust-tls"]
|
||||
|
||||
# unix domain sockets support
|
||||
uds = ["actix-server/uds"]
|
||||
@@ -78,11 +78,11 @@ actix-utils = "0.4.4"
|
||||
actix-router = "0.1.5"
|
||||
actix-rt = "0.2.4"
|
||||
actix-web-codegen = "0.1.2"
|
||||
actix-http = "0.2.7"
|
||||
actix-http = "0.2.9"
|
||||
actix-server = "0.6.0"
|
||||
actix-server-config = "0.1.2"
|
||||
actix-threadpool = "0.1.1"
|
||||
awc = { version = "0.2.2", optional = true }
|
||||
awc = { version = "0.2.4", optional = true }
|
||||
|
||||
bytes = "0.4"
|
||||
derive_more = "0.15.0"
|
||||
@@ -98,7 +98,7 @@ serde = { version = "1.0", features=["derive"] }
|
||||
serde_json = "1.0"
|
||||
serde_urlencoded = "0.6.1"
|
||||
time = "0.1.42"
|
||||
url = { version="1.7", features=["query_encoding"] }
|
||||
url = "2.1"
|
||||
|
||||
# ssl support
|
||||
openssl = { version="0.10", optional = true }
|
||||
|
@@ -1,4 +1,4 @@
|
||||
# Identity service for actix web framework [](https://travis-ci.org/actix/actix-web) [](https://codecov.io/gh/actix/actix-web) [](https://crates.io/crates/actix-identity) [](https://gitter.im/actix/actix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
# Cors Middleware for actix web framework [](https://travis-ci.org/actix/actix-web) [](https://codecov.io/gh/actix/actix-web) [](https://crates.io/crates/actix-cors) [](https://gitter.im/actix/actix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
## Documentation & community resources
|
||||
|
||||
|
@@ -19,7 +19,7 @@ path = "src/lib.rs"
|
||||
|
||||
[dependencies]
|
||||
actix-web = { version = "1.0.2", default-features = false }
|
||||
actix-http = "0.2.4"
|
||||
actix-http = "0.2.9"
|
||||
actix-service = "0.4.1"
|
||||
bitflags = "1"
|
||||
bytes = "0.4"
|
||||
|
@@ -269,9 +269,9 @@ where
|
||||
.map(|protos| protos.windows(2).any(|w| w == H2))
|
||||
.unwrap_or(false);
|
||||
if h2 {
|
||||
(Box::new(sock) as Box<Io>, Protocol::Http2)
|
||||
(Box::new(sock) as Box<dyn Io>, Protocol::Http2)
|
||||
} else {
|
||||
(Box::new(sock) as Box<Io>, Protocol::Http1)
|
||||
(Box::new(sock) as Box<dyn Io>, Protocol::Http1)
|
||||
}
|
||||
}),
|
||||
),
|
||||
@@ -288,9 +288,9 @@ where
|
||||
.map(|protos| protos.windows(2).any(|w| w == H2))
|
||||
.unwrap_or(false);
|
||||
if h2 {
|
||||
(Box::new(sock) as Box<Io>, Protocol::Http2)
|
||||
(Box::new(sock) as Box<dyn Io>, Protocol::Http2)
|
||||
} else {
|
||||
(Box::new(sock) as Box<Io>, Protocol::Http1)
|
||||
(Box::new(sock) as Box<dyn Io>, Protocol::Http1)
|
||||
}
|
||||
}),
|
||||
),
|
||||
|
@@ -1072,7 +1072,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_error_casting() {
|
||||
let err = PayloadError::Overflow;
|
||||
let resp_err: &ResponseError = &err;
|
||||
let resp_err: &dyn ResponseError = &err;
|
||||
let err = resp_err.downcast_ref::<PayloadError>().unwrap();
|
||||
assert_eq!(err.to_string(), "A payload reached size limit.");
|
||||
let not_err = resp_err.downcast_ref::<ContentTypeError>();
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# Changes
|
||||
|
||||
## [0.1.3] - 2019-06-06
|
||||
## [0.1.3] - 2019-08-18
|
||||
|
||||
* Fix ring dependency from actix-web default features for #741.
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# Changes
|
||||
|
||||
## [0.2.4] - 2019-xx-xx
|
||||
## [0.2.4] - 2019-08-13
|
||||
|
||||
### Changed
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "awc"
|
||||
version = "0.2.3"
|
||||
version = "0.2.4"
|
||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
description = "Actix http client."
|
||||
readme = "README.md"
|
||||
@@ -44,7 +44,7 @@ flate2-rust = ["actix-http/flate2-rust"]
|
||||
[dependencies]
|
||||
actix-codec = "0.1.2"
|
||||
actix-service = "0.4.1"
|
||||
actix-http = "0.2.8"
|
||||
actix-http = "0.2.9"
|
||||
base64 = "0.10.1"
|
||||
bytes = "0.4"
|
||||
derive_more = "0.15.0"
|
||||
|
@@ -77,6 +77,11 @@ impl<T> Data<T> {
|
||||
pub fn get_ref(&self) -> &T {
|
||||
self.0.as_ref()
|
||||
}
|
||||
|
||||
/// Convert to the internal Arc<T>
|
||||
pub fn into_inner(self) -> Arc<T> {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Deref for Data<T> {
|
||||
|
@@ -151,5 +151,4 @@ mod tests {
|
||||
let res = block_on(normalize.call(req)).unwrap();
|
||||
assert!(res.status().is_success());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -259,6 +259,7 @@ impl Drop for HttpRequest {
|
||||
if Rc::strong_count(&self.0) == 1 {
|
||||
let v = &mut self.0.pool.0.borrow_mut();
|
||||
if v.len() < 128 {
|
||||
self.extensions_mut().clear();
|
||||
v.push(self.0.clone());
|
||||
}
|
||||
}
|
||||
@@ -494,4 +495,36 @@ mod tests {
|
||||
let resp = call_service(&mut srv, req);
|
||||
assert_eq!(resp.status(), StatusCode::BAD_REQUEST);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_extensions_dropped() {
|
||||
struct Tracker {
|
||||
pub dropped: bool,
|
||||
}
|
||||
struct Foo {
|
||||
tracker: Rc<RefCell<Tracker>>,
|
||||
}
|
||||
impl Drop for Foo {
|
||||
fn drop(&mut self) {
|
||||
self.tracker.borrow_mut().dropped = true;
|
||||
}
|
||||
}
|
||||
|
||||
let tracker = Rc::new(RefCell::new(Tracker { dropped: false }));
|
||||
{
|
||||
let tracker2 = Rc::clone(&tracker);
|
||||
let mut srv = init_service(App::new().data(10u32).service(
|
||||
web::resource("/").to(move |req: HttpRequest| {
|
||||
req.extensions_mut().insert(Foo { tracker: Rc::clone(&tracker2) });
|
||||
HttpResponse::Ok()
|
||||
}),
|
||||
));
|
||||
|
||||
let req = TestRequest::default().to_request();
|
||||
let resp = call_service(&mut srv, req);
|
||||
assert_eq!(resp.status(), StatusCode::OK);
|
||||
}
|
||||
|
||||
assert!(tracker.borrow().dropped);
|
||||
}
|
||||
}
|
||||
|
@@ -763,5 +763,4 @@ mod tests {
|
||||
let resp = call_service(&mut srv, req);
|
||||
assert_eq!(resp.status(), StatusCode::NO_CONTENT);
|
||||
}
|
||||
|
||||
}
|
||||
|
35
src/test.rs
35
src/test.rs
@@ -478,6 +478,16 @@ impl TestRequest {
|
||||
self
|
||||
}
|
||||
|
||||
/// Serialize `data` to a URL encoded form and set it as the request payload. The `Content-Type`
|
||||
/// header is set to `application/x-www-form-urlencoded`.
|
||||
pub fn set_form<T: Serialize>(mut self, data: &T) -> Self {
|
||||
let bytes = serde_urlencoded::to_string(data)
|
||||
.expect("Failed to serialize test data as a urlencoded form");
|
||||
self.req.set_payload(bytes);
|
||||
self.req.set(ContentType::form_url_encoded());
|
||||
self
|
||||
}
|
||||
|
||||
/// Serialize `data` to JSON and set it as the request payload. The `Content-Type` header is
|
||||
/// set to `application/json`.
|
||||
pub fn set_json<T: Serialize>(mut self, data: &T) -> Self {
|
||||
@@ -670,6 +680,31 @@ mod tests {
|
||||
assert_eq!(&result.id, "12345");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_request_response_form() {
|
||||
let mut app = init_service(App::new().service(web::resource("/people").route(
|
||||
web::post().to(|person: web::Form<Person>| {
|
||||
HttpResponse::Ok().json(person.into_inner())
|
||||
}),
|
||||
)));
|
||||
|
||||
let payload = Person {
|
||||
id: "12345".to_string(),
|
||||
name: "User name".to_string(),
|
||||
};
|
||||
|
||||
let req = TestRequest::post()
|
||||
.uri("/people")
|
||||
.set_form(&payload)
|
||||
.to_request();
|
||||
|
||||
assert_eq!(req.content_type(), "application/x-www-form-urlencoded");
|
||||
|
||||
let result: Person = read_response_json(&mut app, req);
|
||||
assert_eq!(&result.id, "12345");
|
||||
assert_eq!(&result.name, "User name");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_request_response_json() {
|
||||
let mut app = init_service(App::new().service(web::resource("/people").route(
|
||||
|
@@ -482,5 +482,4 @@ mod tests {
|
||||
use crate::responder::tests::BodyTest;
|
||||
assert_eq!(resp.body().bin_ref(), b"hello=world&counter=123");
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user