Support Content-Encoding header
authorRichard Whitehouse <github@richardwhiuk.com>
Sun, 29 Oct 2017 15:40:25 +0000 (15:40 +0000)
committerRichard Whitehouse <github@richardwhiuk.com>
Sun, 29 Oct 2017 15:40:25 +0000 (15:40 +0000)
src/codec.rs
src/parser.rs
src/types.rs

index dedd02b1a7c453949a35556d4af5c0344a77ff2d..1ec9c14265bd99ba2e7aed6192bf68ed95efa78a 100644 (file)
@@ -432,8 +432,8 @@ mod tests {
                            MESSAGE\r\nAuthentication-Info:qop=auth\r\nAuthorization:Digest \
                            username=\"Alice\"\r\nCall-ID:f81d4fae-7dec-11d0-a765-00a0c91e6bf6@foo.\
                            bar.com\r\nCall-Info:<http://wwww.example.com/alice/photo.jpg>;\
-                           purpose=icon\r\nContact:*\r\nContent-Disposition:session\r\nVia: \
-                           localhost\r\n\r\n")
+                           purpose=icon\r\nContact:*\r\nContent-Disposition:\
+                           session\r\nContent-Encoding:gzip\r\nVia: localhost\r\n\r\n")
         });
 
         let finished = request.and_then(|(socket, _request)| {
index 643b98b1e572af1cfcb46e7be18bfe3b9be2ecd7..de7320adcbad18a845493062a3db73083afa51ac 100644 (file)
@@ -15,7 +15,7 @@ use types::{PathSegment, HostPort, Host, Hostname, UriParameter, UriHeader, UriH
             AcceptParam, AcceptRange, Coding, Encoding, LanguageRange, Language, AlertParam, Qop,
             AuthenticationInfo, AuthParam, Algorithm, DigestResponse, Credentials, CallId,
             Purpose, InfoParam, Info, NameAddr, ContactParam, ContactTarget, Contact,
-            DispositionType, Handling, DispositionParam};
+            DispositionType, Handling, DispositionParam, ContentCoding};
 
 fn is_mark(c: u8) -> bool {
     c == b'-' || c == b'_' || c == b'.' || c == b'!' || c == b'~' || c == b'*' || c == b'\'' ||
@@ -810,6 +810,12 @@ named!(content_disposition_header<(DispositionType, Vec<DispositionParam>)>, pre
                        tag!(b";"),
                        disp_param)))));
 
+named!(content_encoding_header<Vec<ContentCoding>>, preceded!(
+       alt!(tag!(b"Content-Encoding:") | tag!(b"e:")),
+       separated_nonempty_list!(
+               tag!(b","),
+               token)));
+
 named!(pub header<Header>, alt!(
 // RFC 3261 Headers
        accept_header => { |a| Header::Accept(a) } |
@@ -822,5 +828,6 @@ named!(pub header<Header>, alt!(
        call_id_header => { |c| Header::CallId(c) } |
        call_info_header => { |c| Header::CallInfo(c) } |
        contact_header => { |c| Header::Contact(c) } |
-       content_disposition_header => { |(t, p)| Header::ContentDisposition(t, p) }
+       content_disposition_header => { |(t, p)| Header::ContentDisposition(t, p) } |
+       content_encoding_header => { |e| Header::ContentEncoding(e) }
 ));
index 177a037ee16d25241d108c79ad1b1c8c7780a6f7..2beb957e782d549cc57affbd3730ec8d7bb4e4f0 100644 (file)
@@ -292,6 +292,8 @@ pub enum DispositionParam {
     Generic(GenericParam),
 }
 
+pub type ContentCoding = Vec<u8>;
+
 #[derive(Debug)]
 pub enum Header {
     Accept(Vec<AcceptRange>),
@@ -305,6 +307,7 @@ pub enum Header {
     CallInfo(Vec<Info>),
     Contact(Contact),
     ContentDisposition(DispositionType, Vec<DispositionParam>),
+    ContentEncoding(Vec<ContentCoding>),
     From(Uri),
     To(Uri),
     Extension { name: String, value: String },