@@ -309,17 +309,20 @@ impl fmt::Debug for Headers {
309309
310310// ===== util =====
311311
312- pub fn parse_u64 ( src : & [ u8 ] ) -> Result < u64 , ( ) > {
312+ #[ derive( Debug ) ]
313+ pub struct ParseU64Error ;
314+
315+ pub fn parse_u64 ( src : & [ u8 ] ) -> Result < u64 , ParseU64Error > {
313316 if src. len ( ) > 19 {
314317 // At danger for overflow...
315- return Err ( ( ) ) ;
318+ return Err ( ParseU64Error ) ;
316319 }
317320
318321 let mut ret = 0 ;
319322
320323 for & d in src {
321324 if !( b'0' ..=b'9' ) . contains ( & d) {
322- return Err ( ( ) ) ;
325+ return Err ( ParseU64Error ) ;
323326 }
324327
325328 ret *= 10 ;
@@ -333,7 +336,7 @@ pub fn parse_u64(src: &[u8]) -> Result<u64, ()> {
333336
334337#[ derive( Debug ) ]
335338pub enum PushPromiseHeaderError {
336- InvalidContentLength ( Result < u64 , ( ) > ) ,
339+ InvalidContentLength ( Result < u64 , ParseU64Error > ) ,
337340 NotSafeAndCacheable ,
338341}
339342
@@ -364,9 +367,9 @@ impl PushPromise {
364367 // A promised request "that indicates the presence of a request body
365368 // MUST reset the promised stream with a stream error"
366369 if let Some ( content_length) = req. headers ( ) . get ( header:: CONTENT_LENGTH ) {
367- let parsed_length = parse_u64 ( content_length. as_bytes ( ) ) ;
368- if parsed_length != Ok ( 0 ) {
369- return Err ( InvalidContentLength ( parsed_length ) ) ;
370+ match parse_u64 ( content_length. as_bytes ( ) ) {
371+ Ok ( 0 ) => ( ) ,
372+ parsed => return Err ( InvalidContentLength ( parsed ) ) ,
370373 }
371374 }
372375 // "The server MUST include a method in the :method pseudo-header field
0 commit comments