File tree 5 files changed +13
-11
lines changed
5 files changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -20,12 +20,15 @@ license = "MIT"
20
20
hyper = " ^0.10.6"
21
21
unicase = " ^1.0"
22
22
url = " ^1.0"
23
- rustc-serialize = " ^0.3"
24
23
bitflags = " ^0.8"
25
24
rand = " ^0.3"
26
25
byteorder = " ^1.0"
27
26
sha1 = " ^0.2"
28
27
openssl = { version = " ^0.9.10" , optional = true }
28
+ base64 = " ^0.5"
29
+
30
+ [dev-dependencies ]
31
+ serde_json = " ^1.0"
29
32
30
33
[features ]
31
34
default = [" ssl" ]
Original file line number Diff line number Diff line change 1
1
extern crate websocket;
2
- extern crate rustc_serialize as serialize ;
2
+ extern crate serde_json ;
3
3
4
4
use std:: str:: from_utf8;
5
5
use websocket:: ClientBuilder ;
6
6
use websocket:: Message ;
7
7
use websocket:: message:: Type ;
8
- use serialize:: json;
9
8
10
9
fn main ( ) {
11
10
let addr = "ws://127.0.0.1:9001" . to_string ( ) ;
@@ -93,7 +92,7 @@ fn get_case_count(addr: String) -> usize {
93
92
} ;
94
93
match message. opcode {
95
94
Type :: Text => {
96
- count = json :: decode ( from_utf8 ( & * message. payload ) . unwrap ( ) ) . unwrap ( ) ;
95
+ count = serde_json :: from_str ( from_utf8 ( & * message. payload ) . unwrap ( ) ) . unwrap ( ) ;
97
96
println ! ( "Will run {} cases..." , count) ;
98
97
}
99
98
Type :: Close => {
Original file line number Diff line number Diff line change
1
+ use base64;
1
2
use hyper:: header:: { Header , HeaderFormat } ;
2
3
use hyper:: header:: parsing:: from_one_raw_str;
3
4
use hyper;
4
5
use std:: fmt:: { self , Debug } ;
5
6
use std:: str:: FromStr ;
6
- use serialize:: base64:: { ToBase64 , FromBase64 , STANDARD } ;
7
7
use header:: WebSocketKey ;
8
8
use result:: { WebSocketResult , WebSocketError } ;
9
9
use sha1:: Sha1 ;
@@ -24,7 +24,7 @@ impl FromStr for WebSocketAccept {
24
24
type Err = WebSocketError ;
25
25
26
26
fn from_str ( accept : & str ) -> WebSocketResult < WebSocketAccept > {
27
- match accept . from_base64 ( ) {
27
+ match base64 :: decode ( accept ) {
28
28
Ok ( vec) => {
29
29
if vec. len ( ) != 20 {
30
30
return Err ( WebSocketError :: ProtocolError ( "Sec-WebSocket-Accept must be 20 bytes" ) ) ;
@@ -56,7 +56,7 @@ impl WebSocketAccept {
56
56
/// Return the Base64 encoding of this WebSocketAccept
57
57
pub fn serialize ( & self ) -> String {
58
58
let WebSocketAccept ( accept) = * self ;
59
- accept . to_base64 ( STANDARD )
59
+ base64 :: encode ( & accept )
60
60
}
61
61
}
62
62
Original file line number Diff line number Diff line change
1
+ use base64;
1
2
use hyper:: header:: { Header , HeaderFormat } ;
2
3
use hyper:: header:: parsing:: from_one_raw_str;
3
4
use hyper;
4
5
use std:: fmt:: { self , Debug } ;
5
6
use rand;
6
7
use std:: mem;
7
8
use std:: str:: FromStr ;
8
- use serialize:: base64:: { ToBase64 , FromBase64 , STANDARD } ;
9
9
use result:: { WebSocketResult , WebSocketError } ;
10
10
11
11
/// Represents a Sec-WebSocket-Key header.
@@ -22,7 +22,7 @@ impl FromStr for WebSocketKey {
22
22
type Err = WebSocketError ;
23
23
24
24
fn from_str ( key : & str ) -> WebSocketResult < WebSocketKey > {
25
- match key . from_base64 ( ) {
25
+ match base64 :: decode ( key ) {
26
26
Ok ( vec) => {
27
27
if vec. len ( ) != 16 {
28
28
return Err ( WebSocketError :: ProtocolError ( "Sec-WebSocket-Key must be 16 bytes" ) ) ;
@@ -52,7 +52,7 @@ impl WebSocketKey {
52
52
/// Return the Base64 encoding of this WebSocketKey
53
53
pub fn serialize ( & self ) -> String {
54
54
let WebSocketKey ( key) = * self ;
55
- key . to_base64 ( STANDARD )
55
+ base64 :: encode ( & key )
56
56
}
57
57
}
58
58
Original file line number Diff line number Diff line change 39
39
extern crate hyper;
40
40
extern crate unicase;
41
41
pub extern crate url;
42
- extern crate rustc_serialize as serialize;
43
42
extern crate rand;
44
43
extern crate byteorder;
45
44
extern crate sha1;
46
45
#[ cfg( feature="ssl" ) ]
47
46
extern crate openssl;
47
+ extern crate base64;
48
48
49
49
#[ macro_use]
50
50
extern crate bitflags;
You can’t perform that action at this time.
0 commit comments