mirror of
https://github.com/actix/actix-extras.git
synced 2025-06-25 01:51:23 +02:00
call disconnect on write error
This commit is contained in:
@ -9,6 +9,7 @@ use bytes::Bytes;
|
||||
use futures::Stream;
|
||||
use rand::distributions::Alphanumeric;
|
||||
use rand::Rng;
|
||||
use std::time::Duration;
|
||||
|
||||
#[cfg(feature = "alpn")]
|
||||
extern crate openssl;
|
||||
@ -120,6 +121,31 @@ fn test_large_bin() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_client_frame_size() {
|
||||
let data = rand::thread_rng()
|
||||
.sample_iter(&Alphanumeric)
|
||||
.take(131_072)
|
||||
.collect::<String>();
|
||||
|
||||
let mut srv = test::TestServer::new(|app| {
|
||||
app.handler(|req| -> Result<HttpResponse> {
|
||||
let mut resp = ws::handshake(req)?;
|
||||
let stream = ws::WsStream::new(req.payload()).max_size(131_072);
|
||||
|
||||
let body = ws::WebsocketContext::create(req.clone(), Ws, stream);
|
||||
Ok(resp.body(body))
|
||||
})
|
||||
});
|
||||
let (reader, mut writer) = srv.ws().unwrap();
|
||||
|
||||
writer.binary(data.clone());
|
||||
match srv.execute(reader.into_future()).err().unwrap().0 {
|
||||
ws::ProtocolError::Overflow => (),
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
|
||||
struct Ws2 {
|
||||
count: usize,
|
||||
bin: bool,
|
||||
|
Reference in New Issue
Block a user