mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Request header and postdata support for XHR
This commit is contained in:
parent
096eea8369
commit
5f860bb612
10 changed files with 236 additions and 63 deletions
|
@ -37,6 +37,7 @@ impl ByteString {
|
|||
}
|
||||
}).collect())
|
||||
}
|
||||
|
||||
pub fn is_token(&self) -> bool {
|
||||
let ByteString(ref vec) = *self;
|
||||
vec.iter().all(|&x| {
|
||||
|
@ -51,6 +52,55 @@ impl ByteString {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn is_field_value(&self) -> bool {
|
||||
// Classifications of characters necessary for the [CRLF] (SP|HT) rule
|
||||
#[deriving(Eq)]
|
||||
enum PreviousCharacter {
|
||||
Other,
|
||||
CR,
|
||||
LF,
|
||||
SP_HT // SP or HT
|
||||
}
|
||||
let ByteString(ref vec) = *self;
|
||||
let mut prev = Other; // The previous character
|
||||
vec.iter().all(|&x| {
|
||||
// http://tools.ietf.org/html/rfc2616#section-2.2
|
||||
match x {
|
||||
13 => { // CR
|
||||
if prev == Other || prev == SP_HT {
|
||||
prev = CR;
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
},
|
||||
10 => { // LF
|
||||
if prev == CR {
|
||||
prev = LF;
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
},
|
||||
32 | 9 => { // SP | HT
|
||||
if prev == LF || prev == SP_HT {
|
||||
prev = SP_HT;
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
},
|
||||
0..31 | 127 => false, // CTLs
|
||||
x if x > 127 => false, // non ASCII
|
||||
_ if prev == Other || prev == SP_HT => {
|
||||
prev = Other;
|
||||
true
|
||||
},
|
||||
_ => false // Previous character was a CR/LF but not part of the [CRLF] (SP|HT) rule
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl Hash for ByteString {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue