AbsoluteUri, Uri, HierarchicalPath, Authority, UriPath, UserInfo, AbsolutePath,
Scheme, Method, Transport, UserParam, Version, RequestLine, StatusLine, TopLine,
Header, MediaType, MediaFullType, MediaParameter, MediaRange, GenericParam,
- AcceptParam, AcceptRange, Coding, Encoding, LanguageRange, Language, AlertParam};
+ AcceptParam, AcceptRange, Coding, Encoding, LanguageRange, Language, AlertParam, Qop,
+ AuthenticationInfo};
fn is_mark(c: u8) -> bool {
c == b'-' || c == b'_' || c == b'.' || c == b'!' || c == b'~' || c == b'*' || c == b'\'' ||
c == b'*' || c == b'_' || c == b'+' || c == b'`' || c == b'\'' || c == b'~'
}
+fn is_lhex_digit(c: u8) -> bool {
+ nom::is_digit(c) || (c >= b'a' && c <= b'f')
+}
+
named!(token<Vec<u8>>, many1!(take_1!(is_token)));
named!(method<Method>, alt!(
named!(alphanumeric<&[u8], u8>, take_1!(nom::is_alphanumeric));
named!(digit<&[u8], u8>, take_1!(nom::is_digit));
named!(hex<&[u8], u8>, take_1!(nom::is_hex_digit));
+named!(lhex<&[u8], u8>, take_1!(is_lhex_digit));
fn escaped(input: &[u8]) -> IResult<&[u8], u8> {
let result = preceded!(input, tag!(b"%"), pair!(hex, hex));
tag!(b","),
method)));
+named!(nextnonce<Vec<u8>>, preceded!(
+ tag!(b"nc="),
+ quoted_string));
+
+named!(qop_value<Qop>, alt!(
+ tag!(b"auth") => { |x| Qop::Auth } |
+ tag!(b"auth-init") => { |x| Qop::AuthInit } |
+ token => { |x| Qop::Token(x) }));
+
+named!(message_qop<Qop>, preceded!(
+ tag!(b"qop="),
+ qop_value));
+
+named!(response_digest<Vec<u8>>, delimited!(
+ tag!(b"\""),
+ many0!(hex),
+ tag!(b"\"")));
+
+named!(response_auth<Vec<u8>>, preceded!(
+ tag!(b"rspauth="),
+ response_digest));
+
+named!(cnonce<Vec<u8>>, preceded!(
+ tag!(b"cnonce="),
+ quoted_string));
+
+named!(nc_value<Vec<u8>>, many1!(lhex));
+
+named!(nonce_count<Vec<u8>>, preceded!(
+ tag!(b"nc="),
+ nc_value));
+
+named!(ainfo<AuthenticationInfo>, alt!(
+ nextnonce => { |n| AuthenticationInfo::NextNonce(n) } |
+ message_qop => { |m| AuthenticationInfo::MessageQop(m) } |
+ response_auth => { |r| AuthenticationInfo::ResponseAuth(r) } |
+ cnonce => { |c| AuthenticationInfo::Cnonce(c) } |
+ nonce_count => { |n| AuthenticationInfo::NonceCount(n) }));
+
+named!(authentication_info_header<Vec<AuthenticationInfo>>, preceded!(
+ tag!(b"Authentication-Info:"),
+ separated_nonempty_list!(
+ tag!(b","),
+ ainfo)));
+
named!(pub header<Header>, alt!(
// RFC 3261 Headers
accept_header => { |a| Header::Accept(a) } |
accept_encoding_header => { |a| Header::AcceptEncoding(a) } |
accept_language_header => { |a| Header::AcceptLanguage(a) } |
alert_info_header => { |a| Header::AlertInfo(a) } |
- allow_header => { |a| Header::Allow(a) }
+ allow_header => { |a| Header::Allow(a) } |
+ authentication_info_header => { |a| Header::AuthenticationInfo(a) }
));