Support Proxy-Require header
authorRichard Whitehouse <github@richardwhiuk.com>
Sun, 29 Oct 2017 20:20:27 +0000 (20:20 +0000)
committerRichard Whitehouse <github@richardwhiuk.com>
Sun, 29 Oct 2017 20:20:27 +0000 (20:20 +0000)
src/codec.rs
src/parser.rs
src/types.rs

index 223f5ed2da31946dc314c061db4bf345f3958fee..7deb71f933cc1cac901d85629b703cd9c2b900f5 100644 (file)
@@ -442,7 +442,7 @@ mod tests {
                            bell-tel.com\r\nMax-Forwards:32\r\nMIME-Version:2.0\r\nMin-Expires:\
                            30\r\nOrganization:Foobar\r\nPriority:normal\r\nProxy-Authenticate:\
                            Digest realm=\"atlanta.com\"\r\nProxy-Authorization:Digest \
-                           username=\"Bob\"\r\nVia: localhost\r\n\r\n")
+                           username=\"Bob\"\r\nProxy-Require:foo\r\nVia: localhost\r\n\r\n")
         });
 
         let finished = request.and_then(|(socket, _request)| {
index e7738d72490b1202da48ae6361f81c48d83de003..712388304d98d567d9ac0a8e55417c48a2737b9c 100644 (file)
@@ -17,7 +17,7 @@ use types::{PathSegment, HostPort, Host, Hostname, UriParameter, UriHeader, UriH
             Credentials, CallId, Purpose, InfoParam, Info, NameAddr, ContactParam, Target,
             Contact, DispositionType, Handling, DispositionParam, ContentCoding, Day, Month, Date,
             Time, DateTime, ErrorUri, FromParam, From, Priority, Domain, DigestChallenge,
-            Challenge};
+            Challenge, OptionTag};
 
 fn is_mark(c: u8) -> bool {
     c == b'-' || c == b'_' || c == b'.' || c == b'!' || c == b'~' || c == b'*' || c == b'\'' ||
@@ -1037,6 +1037,12 @@ named!(proxy_authorization_header<Credentials>, preceded!(
        tag!(b"Proxy-Authorization:"),
        credentials));
 
+named!(proxy_require_header<Vec<OptionTag>>, preceded!(
+       tag!(b"Proxy-Require:"),
+       separated_nonempty_list!(
+               tag!(b","),
+               token)));
+
 named!(pub header<Header>, alt!(
 // RFC 3261 Headers
        accept_header => { |a| Header::Accept(a) } |
@@ -1066,5 +1072,6 @@ named!(pub header<Header>, alt!(
        organization_header => { |o| Header::Organization(o) } |
        priority_header => { |p| Header::Priority(p) } |
        proxy_authenticate_header => { |p| Header::ProxyAuthenticate(p) } |
-       proxy_authorization_header => { |p| Header::ProxyAuthorization(p) }
+       proxy_authorization_header => { |p| Header::ProxyAuthorization(p) } |
+       proxy_require_header => { |p| Header::ProxyRequire(p) }
 ));
index 201379d7dfaa44ca40519601c2d1d9c367b7fb94..17fa3a39b7f415f98b10e404a7fca5641b374725 100644 (file)
@@ -373,6 +373,8 @@ pub enum Challenge {
     Other(Vec<u8>, Vec<AuthParam>),
 }
 
+pub type OptionTag = Vec<u8>;
+
 #[derive(Debug)]
 pub enum Header {
     Accept(Vec<AcceptRange>),
@@ -403,6 +405,7 @@ pub enum Header {
     Priority(Priority),
     ProxyAuthenticate(Challenge),
     ProxyAuthorization(Credentials),
+    ProxyRequire(Vec<OptionTag>),
     To(Uri),
     Extension { name: String, value: String },
 }