@@ -120,8 +120,7 @@ fn eat<R: Read>(rdr: &mut R, bytes: &[u8]) -> io::Result<()> {
120
120
match try!( rdr. read ( & mut buf) ) {
121
121
1 if buf[ 0 ] == b => ( ) ,
122
122
_ => return Err ( io:: Error :: new ( io:: ErrorKind :: InvalidInput ,
123
- "Invalid characters found" ,
124
- None ) )
123
+ "Invalid characters found" ) ) ,
125
124
}
126
125
}
127
126
Ok ( ( ) )
@@ -135,8 +134,7 @@ fn read_chunk_size<R: Read>(rdr: &mut R) -> io::Result<u64> {
135
134
match try!( $rdr. read( & mut buf) ) {
136
135
1 => buf[ 0 ] ,
137
136
_ => return Err ( io:: Error :: new( io:: ErrorKind :: InvalidInput ,
138
- "Invalid chunk size line" ,
139
- None ) ) ,
137
+ "Invalid chunk size line" ) ) ,
140
138
141
139
}
142
140
} )
@@ -163,8 +161,7 @@ fn read_chunk_size<R: Read>(rdr: &mut R) -> io::Result<u64> {
163
161
match byte ! ( rdr) {
164
162
LF => break ,
165
163
_ => return Err ( io:: Error :: new ( io:: ErrorKind :: InvalidInput ,
166
- "Invalid chunk size line" ,
167
- None ) )
164
+ "Invalid chunk size line" ) )
168
165
169
166
}
170
167
} ,
@@ -190,8 +187,7 @@ fn read_chunk_size<R: Read>(rdr: &mut R) -> io::Result<u64> {
190
187
// other octet, the chunk size line is invalid!
191
188
_ => {
192
189
return Err ( io:: Error :: new ( io:: ErrorKind :: InvalidInput ,
193
- "Invalid chunk size line" ,
194
- None ) )
190
+ "Invalid chunk size line" ) ) ;
195
191
}
196
192
}
197
193
}
@@ -441,7 +437,7 @@ mod tests {
441
437
use std:: str:: from_utf8;
442
438
let mut w = super :: HttpWriter :: SizedWriter ( Vec :: new ( ) , 8 ) ;
443
439
w. write_all ( b"foo bar" ) . unwrap ( ) ;
444
- assert_eq ! ( w. write( b"baz" ) , Ok ( 1 ) ) ;
440
+ assert_eq ! ( w. write( b"baz" ) . unwrap ( ) , 1 ) ;
445
441
446
442
let buf = w. end ( ) . unwrap ( ) ;
447
443
let s = from_utf8 ( buf. as_ref ( ) ) . unwrap ( ) ;
@@ -450,22 +446,22 @@ mod tests {
450
446
451
447
#[ test]
452
448
fn test_read_chunk_size ( ) {
453
- fn read ( s : & str , result : io :: Result < u64 > ) {
454
- assert_eq ! ( read_chunk_size( & mut s. as_bytes( ) ) , result) ;
449
+ fn read ( s : & str , result : u64 ) {
450
+ assert_eq ! ( read_chunk_size( & mut s. as_bytes( ) ) . unwrap ( ) , result) ;
455
451
}
456
452
457
453
fn read_err ( s : & str ) {
458
454
assert_eq ! ( read_chunk_size( & mut s. as_bytes( ) ) . unwrap_err( ) . kind( ) , io:: ErrorKind :: InvalidInput ) ;
459
455
}
460
456
461
- read ( "1\r \n " , Ok ( 1 ) ) ;
462
- read ( "01\r \n " , Ok ( 1 ) ) ;
463
- read ( "0\r \n " , Ok ( 0 ) ) ;
464
- read ( "00\r \n " , Ok ( 0 ) ) ;
465
- read ( "A\r \n " , Ok ( 10 ) ) ;
466
- read ( "a\r \n " , Ok ( 10 ) ) ;
467
- read ( "Ff\r \n " , Ok ( 255 ) ) ;
468
- read ( "Ff \r \n " , Ok ( 255 ) ) ;
457
+ read ( "1\r \n " , 1 ) ;
458
+ read ( "01\r \n " , 1 ) ;
459
+ read ( "0\r \n " , 0 ) ;
460
+ read ( "00\r \n " , 0 ) ;
461
+ read ( "A\r \n " , 10 ) ;
462
+ read ( "a\r \n " , 10 ) ;
463
+ read ( "Ff\r \n " , 255 ) ;
464
+ read ( "Ff \r \n " , 255 ) ;
469
465
// Missing LF or CRLF
470
466
read_err ( "F\r F" ) ;
471
467
read_err ( "F" ) ;
@@ -475,14 +471,14 @@ mod tests {
475
471
read_err ( "-\r \n " ) ;
476
472
read_err ( "-1\r \n " ) ;
477
473
// Acceptable (if not fully valid) extensions do not influence the size
478
- read ( "1;extension\r \n " , Ok ( 1 ) ) ;
479
- read ( "a;ext name=value\r \n " , Ok ( 10 ) ) ;
480
- read ( "1;extension;extension2\r \n " , Ok ( 1 ) ) ;
481
- read ( "1;;; ;\r \n " , Ok ( 1 ) ) ;
482
- read ( "2; extension...\r \n " , Ok ( 2 ) ) ;
483
- read ( "3 ; extension=123\r \n " , Ok ( 3 ) ) ;
484
- read ( "3 ;\r \n " , Ok ( 3 ) ) ;
485
- read ( "3 ; \r \n " , Ok ( 3 ) ) ;
474
+ read ( "1;extension\r \n " , 1 ) ;
475
+ read ( "a;ext name=value\r \n " , 10 ) ;
476
+ read ( "1;extension;extension2\r \n " , 1 ) ;
477
+ read ( "1;;; ;\r \n " , 1 ) ;
478
+ read ( "2; extension...\r \n " , 2 ) ;
479
+ read ( "3 ; extension=123\r \n " , 3 ) ;
480
+ read ( "3 ;\r \n " , 3 ) ;
481
+ read ( "3 ; \r \n " , 3 ) ;
486
482
// Invalid extensions cause an error
487
483
read_err ( "1 invalid extension\r \n " ) ;
488
484
read_err ( "1 A\r \n " ) ;
0 commit comments