mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Move trim_http_whitespace to net_traits.
This commit is contained in:
parent
6a1722e18d
commit
80fc666734
5 changed files with 47 additions and 52 deletions
|
@ -46,6 +46,7 @@ use js::jsapi::{JSContext, JS_ParseJSON, RootedValue};
|
|||
use js::jsval::{JSVal, NullValue, UndefinedValue};
|
||||
use msg::constellation_msg::{PipelineId, ReferrerPolicy};
|
||||
use net_traits::CoreResourceMsg::Load;
|
||||
use net_traits::trim_http_whitespace;
|
||||
use net_traits::{AsyncResponseListener, AsyncResponseTarget, Metadata, NetworkError, RequestSource};
|
||||
use net_traits::{LoadConsumer, LoadContext, LoadData, ResourceCORSData, CoreResourceThread, LoadOrigin};
|
||||
use network_listener::{NetworkListener, PreInvoke};
|
||||
|
@ -1506,27 +1507,3 @@ pub fn is_field_value(slice: &[u8]) -> bool {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Normalize `self`, as defined by
|
||||
/// [the Fetch Spec](https://fetch.spec.whatwg.org/#concept-header-value-normalize).
|
||||
pub fn trim_http_whitespace(mut slice: &[u8]) -> &[u8] {
|
||||
const HTTP_WS_BYTES: &'static [u8] = b"\x09\x0A\x0D\x20";
|
||||
|
||||
loop {
|
||||
match slice.split_first() {
|
||||
Some((first, remainder)) if HTTP_WS_BYTES.contains(first) =>
|
||||
slice = remainder,
|
||||
_ => break,
|
||||
}
|
||||
}
|
||||
|
||||
loop {
|
||||
match slice.split_last() {
|
||||
Some((last, remainder)) if HTTP_WS_BYTES.contains(last) =>
|
||||
slice = remainder,
|
||||
_ => break,
|
||||
}
|
||||
}
|
||||
|
||||
slice
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue