1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-14 02:08:44 +02:00

Compare commits

..

7 Commits
v0.6.13 ... 0.6

Author SHA1 Message Date
Nikolay Kim
3378247bee prepare release 2018-07-11 13:27:50 +06:00
Nikolay Kim
7507412a1d fix h2 compatibility 2018-07-11 13:26:51 +06:00
Nikolay Kim
6b9a193aa8 update changelog 2018-07-11 13:26:40 +06:00
Gary Hai
c2979760b5 Fix duplicate tail of StaticFiles with index_file. (#344) 2018-06-25 19:37:24 +03:00
Nikolay Kim
1fcf1d4a49 prepare release 2018-06-21 09:47:46 +06:00
Nikolay Kim
4012606910 SendRequest execution fails with the entered unreachable code #329 2018-06-21 09:47:28 +06:00
Nikolay Kim
e975124630 Allow to disable masking for websockets client 2018-06-21 09:38:59 +06:00
6 changed files with 46 additions and 13 deletions

View File

@@ -1,5 +1,25 @@
# Changes
## [0.6.15] - 2018-07-11
### Fixed
* Fix h2 compatibility #352
* Fix duplicate tail of StaticFiles with index_file. #344
## [0.6.14] - 2018-06-21
### Added
* Allow to disable masking for websockets client
### Fixed
* SendRequest execution fails with the "internal error: entered unreachable code" #329
## [0.6.13] - 2018-06-13
### Fixed

View File

@@ -1,6 +1,6 @@
[package]
name = "actix-web"
version = "0.6.13"
version = "0.6.15"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix web is a simple, pragmatic and extremely fast web framework for Rust."
readme = "README.md"

View File

@@ -380,7 +380,7 @@ impl Pipeline {
match self.timeout.as_mut().unwrap().poll() {
Ok(Async::Ready(())) => return Err(SendRequestError::Timeout),
Ok(Async::NotReady) => (),
Err(_) => unreachable!(),
Err(e) => return Err(e.into()),
}
}
Ok(())

View File

@@ -653,10 +653,6 @@ impl<S: 'static> Handler<S> for StaticFiles<S> {
// TODO: It'd be nice if there were a good usable URL manipulation
// library
let mut new_path: String = req.path().to_owned();
for el in relpath.iter() {
new_path.push_str(&el.to_string_lossy());
new_path.push('/');
}
if !new_path.ends_with('/') {
new_path.push('/');
}
@@ -1017,7 +1013,8 @@ mod tests {
#[test]
fn test_redirect_to_index() {
let mut st = StaticFiles::new(".").index_file("index.html");
let mut req = HttpRequest::default();
let mut req = TestRequest::default().uri("/tests").finish();
req.match_info_mut().add("tail", "tests");
let resp = st.handle(req).respond_to(&HttpRequest::default()).unwrap();
@@ -1028,7 +1025,7 @@ mod tests {
"/tests/index.html"
);
let mut req = HttpRequest::default();
let mut req = TestRequest::default().uri("/tests/").finish();
req.match_info_mut().add("tail", "tests/");
let resp = st.handle(req).respond_to(&HttpRequest::default()).unwrap();
@@ -1043,7 +1040,7 @@ mod tests {
#[test]
fn test_redirect_to_index_nested() {
let mut st = StaticFiles::new(".").index_file("Cargo.toml");
let mut req = HttpRequest::default();
let mut req = TestRequest::default().uri("/tools/wsload").finish();
req.match_info_mut().add("tail", "tools/wsload");
let resp = st.handle(req).respond_to(&HttpRequest::default()).unwrap();

View File

@@ -67,7 +67,7 @@ where
flags: Flags::empty(),
tasks: VecDeque::new(),
state: State::Handshake(server::handshake(IoWrapper {
unread: Some(buf),
unread: if buf.is_empty() { None } else { Some(buf) },
inner: io,
})),
keepalive_timer: None,

View File

@@ -113,6 +113,7 @@ pub struct Client {
protocols: Option<String>,
conn: Addr<Unsync, ClientConnector>,
max_size: usize,
no_masking: bool,
}
impl Client {
@@ -132,6 +133,7 @@ impl Client {
origin: None,
protocols: None,
max_size: 65_536,
no_masking: false,
conn,
};
cl.request.uri(uri.as_ref());
@@ -186,6 +188,12 @@ impl Client {
self
}
/// Disable payload masking. By default ws client masks frame payload.
pub fn no_masking(mut self) -> Self {
self.no_masking = true;
self
}
/// Set request header
pub fn header<K, V>(mut self, key: K, value: V) -> Self
where
@@ -248,7 +256,7 @@ impl Client {
}
// start handshake
ClientHandshake::new(request, self.max_size)
ClientHandshake::new(request, self.max_size, self.no_masking)
}
}
}
@@ -269,10 +277,13 @@ pub struct ClientHandshake {
key: String,
error: Option<ClientError>,
max_size: usize,
no_masking: bool,
}
impl ClientHandshake {
fn new(mut request: ClientRequest, max_size: usize) -> ClientHandshake {
fn new(
mut request: ClientRequest, max_size: usize, no_masking: bool,
) -> ClientHandshake {
// Generate a random key for the `Sec-WebSocket-Key` header.
// a base64-encoded (see Section 4 of [RFC4648]) value that,
// when decoded, is 16 bytes in length (RFC 6455)
@@ -292,6 +303,7 @@ impl ClientHandshake {
ClientHandshake {
key,
max_size,
no_masking,
request: Some(request.send()),
tx: Some(tx),
error: None,
@@ -305,6 +317,7 @@ impl ClientHandshake {
tx: None,
error: Some(err),
max_size: 0,
no_masking: false,
}
}
@@ -415,6 +428,7 @@ impl Future for ClientHandshake {
ClientReader {
inner: Rc::clone(&inner),
max_size: self.max_size,
no_masking: self.no_masking,
},
ClientWriter { inner },
)))
@@ -424,6 +438,7 @@ impl Future for ClientHandshake {
pub struct ClientReader {
inner: Rc<UnsafeCell<Inner>>,
max_size: usize,
no_masking: bool,
}
impl fmt::Debug for ClientReader {
@@ -445,13 +460,14 @@ impl Stream for ClientReader {
fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> {
let max_size = self.max_size;
let no_masking = self.no_masking;
let inner = self.as_mut();
if inner.closed {
return Ok(Async::Ready(None));
}
// read
match Frame::parse(&mut inner.rx, false, max_size) {
match Frame::parse(&mut inner.rx, no_masking, max_size) {
Ok(Async::Ready(Some(frame))) => {
let (_finished, opcode, payload) = frame.unpack();