File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -953,17 +953,18 @@ fn parse_token<'a>(bytes: &mut Bytes<'a>) -> Result<&'a str> {
953
953
#[ allow( missing_docs) ]
954
954
// WARNING: Exported for internal benchmarks, not fit for public consumption
955
955
pub fn parse_uri < ' a > ( bytes : & mut Bytes < ' a > ) -> Result < & ' a str > {
956
- // URI must have at least one char
957
956
let uri_len = simd:: match_uri_vectored ( bytes. as_ref ( ) ) ;
958
- if uri_len == 0 {
959
- return Err ( Error :: Token ) ;
960
- }
961
957
// SAFETY: these bytes have just been matched here above.
962
958
unsafe { bytes. advance ( uri_len) } ;
959
+
963
960
let uri_slice = bytes. slice ( ) ;
964
961
965
962
let space_delim = next ! ( bytes) ;
966
963
if space_delim == b' ' {
964
+ // URI must have at least one char
965
+ if uri_len == 0 {
966
+ return Err ( Error :: Token ) ;
967
+ }
967
968
// SAFETY: all bytes within `uri_slice` must have been `is_token` and therefore also utf-8.
968
969
let uri = unsafe { str:: from_utf8_unchecked ( uri_slice) } ;
969
970
Ok ( Status :: Complete ( uri) )
You can’t perform that action at this time.
0 commit comments