1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-26 18:37:41 +02:00

added support for websocket testing

This commit is contained in:
Nikolay Kim
2018-01-30 15:13:33 -08:00
parent 76f9542df7
commit 577f91206c
6 changed files with 134 additions and 10 deletions

View File

@ -1,6 +1,6 @@
//! Http client request
#![allow(unused_imports, dead_code)]
use std::{io, str};
use std::{fmt, io, str};
use std::rc::Rc;
use std::time::Duration;
use std::cell::UnsafeCell;
@ -299,8 +299,8 @@ impl Future for WsHandshake {
let match_key = if let Some(key) = resp.headers().get(
HeaderName::try_from("SEC-WEBSOCKET-ACCEPT").unwrap())
{
// ... field is constructed by concatenating /key/ ...
// ... with the string "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" (RFC 6455)
// field is constructed by concatenating /key/
// with the string "258EAFA5-E914-47DA-95CA-C5AB0DC85B11" (RFC 6455)
const WS_GUID: &[u8] = b"258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
let mut sha1 = Sha1::new();
sha1.update(self.key.as_ref());
@ -336,6 +336,12 @@ pub struct WsClientReader {
inner: Rc<UnsafeCell<Inner>>
}
impl fmt::Debug for WsClientReader {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "WsClientReader()")
}
}
impl WsClientReader {
#[inline]
fn as_mut(&mut self) -> &mut Inner {

View File

@ -74,7 +74,7 @@ const SEC_WEBSOCKET_VERSION: &str = "SEC-WEBSOCKET-VERSION";
/// `WebSocket` Message
#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub enum Message {
Text(String),
Binary(Binary),