http2: code cleanup for http2_normalize_host

Just separate the steps in parsing, and deduplicate code

(cherry picked from commit 52c01543c9)
pull/16171/head
Philippe Antoine 2 weeks ago committed by Victor Julien
parent 14eb3d3521
commit 9d5230eff0

@ -619,15 +619,13 @@ fn http2_normalize_host(ve: Http2Header) -> Http2Header {
Http2Header::Single(v) => v,
Http2Header::Multiple(v) => v.as_slice(),
};
let (start, end) = match vs.iter().position(|&x| x == b'@') {
Some(i) => match &vs[i + 1..].iter().position(|&x| x == b':') {
Some(j) => (i + 1, i + 1 + j),
None => (i + 1, vs.len()),
},
None => match vs.iter().position(|&x| x == b':') {
Some(i) => (0, i),
None => (0, vs.len()),
},
let start = match vs.iter().position(|&x| x == b'@') {
Some(i) => i + 1,
None => 0,
};
let end = match &vs[start..].iter().position(|&x| x == b':') {
Some(j) => start + j,
None => vs.len(),
};
return match ve {
Http2Header::Single(v) => {

Loading…
Cancel
Save