File tree 1 file changed +4
-6
lines changed
1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -851,18 +851,16 @@ pub fn parse_method<'a>(bytes: &mut Bytes<'a>) -> Result<&'a str> {
851
851
Some ( GET ) => {
852
852
// SAFETY: matched the ASCII string and boundary checked
853
853
let method = unsafe {
854
- bytes. advance ( 4 ) ;
855
- let buf = bytes. slice_skip ( 1 ) ;
856
- str:: from_utf8_unchecked ( buf)
854
+ bytes. advance_and_commit ( 4 ) ;
855
+ str:: from_utf8_unchecked ( GET [ ..GET . len ( ) -1 ] )
857
856
} ;
858
857
Ok ( Status :: Complete ( method) )
859
858
}
860
859
Some ( POST ) if bytes. peek_ahead ( 4 ) == Some ( b' ' ) => {
861
860
// SAFETY: matched the ASCII string and boundary checked
862
861
let method = unsafe {
863
- bytes. advance ( 5 ) ;
864
- let buf = bytes. slice_skip ( 1 ) ;
865
- str:: from_utf8_unchecked ( buf)
862
+ bytes. advance_and_commit ( 5 ) ;
863
+ str:: from_utf8_unchecked ( POST [ ..] )
866
864
} ;
867
865
Ok ( Status :: Complete ( method) )
868
866
}
You can’t perform that action at this time.
0 commit comments