1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-07-01 12:15:08 +02:00

convert to 2018 edition

This commit is contained in:
Nikolay Kim
2018-12-06 14:32:52 -08:00
parent c0f8bc9e90
commit e9121025b7
40 changed files with 310 additions and 294 deletions

View File

@ -5,10 +5,9 @@ use cookie::Cookie;
use http::header::{HeaderName, HeaderValue};
use http::{Error as HttpError, HttpTryFrom};
use client::{ClientRequest, ClientRequestBuilder};
use header::IntoHeaderValue;
use super::ClientError;
use crate::client::{ClientRequest, ClientRequestBuilder};
use crate::header::IntoHeaderValue;
/// `WebSocket` connection
pub struct Connect {

View File

@ -2,12 +2,11 @@
use std::io;
use actix_net::connector::ConnectorError;
use http::header::HeaderValue;
use http::StatusCode;
use failure::Fail;
use http::{header::HeaderValue, Error as HttpError, StatusCode};
use error::ParseError;
use http::Error as HttpError;
use ws::ProtocolError;
use crate::error::ParseError;
use crate::ws::ProtocolError;
/// Websocket client error
#[derive(Fail, Debug)]

View File

@ -6,17 +6,18 @@ use actix_net::connector::{Connect as TcpConnect, ConnectorError, DefaultConnect
use actix_net::service::Service;
use base64;
use futures::future::{err, Either, FutureResult};
use futures::{Async, Future, Poll, Sink, Stream};
use futures::{try_ready, Async, Future, Poll, Sink, Stream};
use http::header::{self, HeaderValue};
use http::{HttpTryFrom, StatusCode};
use log::trace;
use rand;
use sha1::Sha1;
use tokio_io::{AsyncRead, AsyncWrite};
use body::BodyLength;
use client::ClientResponse;
use h1;
use ws::Codec;
use crate::body::BodyLength;
use crate::client::ClientResponse;
use crate::h1;
use crate::ws::Codec;
use super::{ClientError, Connect, Protocol};

View File

@ -1,10 +1,11 @@
use byteorder::{ByteOrder, LittleEndian, NetworkEndian};
use bytes::{BufMut, Bytes, BytesMut};
use log::debug;
use rand;
use ws::mask::apply_mask;
use ws::proto::{CloseCode, CloseReason, OpCode};
use ws::ProtocolError;
use crate::ws::mask::apply_mask;
use crate::ws::proto::{CloseCode, CloseReason, OpCode};
use crate::ws::ProtocolError;
/// A struct representing a `WebSocket` frame.
#[derive(Debug)]

View File

@ -5,10 +5,12 @@
//! communicate with the peer.
use std::io;
use error::ResponseError;
use failure::Fail;
use http::{header, Method, StatusCode};
use request::Request;
use response::{Response, ResponseBuilder};
use crate::error::ResponseError;
use crate::request::Request;
use crate::response::{Response, ResponseBuilder};
mod client;
mod codec;
@ -221,7 +223,8 @@ mod tests {
.header(
header::UPGRADE,
header::HeaderValue::from_static("websocket"),
).finish();
)
.finish();
assert_eq!(
HandshakeError::NoConnectionUpgrade,
verify_handshake(&req).err().unwrap()
@ -231,10 +234,12 @@ mod tests {
.header(
header::UPGRADE,
header::HeaderValue::from_static("websocket"),
).header(
)
.header(
header::CONNECTION,
header::HeaderValue::from_static("upgrade"),
).finish();
)
.finish();
assert_eq!(
HandshakeError::NoVersionHeader,
verify_handshake(&req).err().unwrap()
@ -244,13 +249,16 @@ mod tests {
.header(
header::UPGRADE,
header::HeaderValue::from_static("websocket"),
).header(
)
.header(
header::CONNECTION,
header::HeaderValue::from_static("upgrade"),
).header(
)
.header(
header::SEC_WEBSOCKET_VERSION,
header::HeaderValue::from_static("5"),
).finish();
)
.finish();
assert_eq!(
HandshakeError::UnsupportedVersion,
verify_handshake(&req).err().unwrap()
@ -260,13 +268,16 @@ mod tests {
.header(
header::UPGRADE,
header::HeaderValue::from_static("websocket"),
).header(
)
.header(
header::CONNECTION,
header::HeaderValue::from_static("upgrade"),
).header(
)
.header(
header::SEC_WEBSOCKET_VERSION,
header::HeaderValue::from_static("13"),
).finish();
)
.finish();
assert_eq!(
HandshakeError::BadWebsocketKey,
verify_handshake(&req).err().unwrap()
@ -276,16 +287,20 @@ mod tests {
.header(
header::UPGRADE,
header::HeaderValue::from_static("websocket"),
).header(
)
.header(
header::CONNECTION,
header::HeaderValue::from_static("upgrade"),
).header(
)
.header(
header::SEC_WEBSOCKET_VERSION,
header::HeaderValue::from_static("13"),
).header(
)
.header(
header::SEC_WEBSOCKET_KEY,
header::HeaderValue::from_static("13"),
).finish();
)
.finish();
assert_eq!(
StatusCode::SWITCHING_PROTOCOLS,
handshake_response(&req).finish().status()

View File

@ -5,8 +5,8 @@ use actix_net::service::{NewService, Service};
use futures::future::{ok, FutureResult};
use futures::{Async, IntoFuture, Poll};
use h1::Codec;
use request::Request;
use crate::h1::Codec;
use crate::request::Request;
use super::{verify_handshake, HandshakeError};