Scheme, Method, Transport, UserParam, Version, RequestLine, StatusLine, TopLine,
Header, MediaType, MediaFullType, MediaParameter, MediaRange, GenericParam,
AcceptParam, AcceptRange, Coding, Encoding, LanguageRange, Language, AlertParam, Qop,
- AuthenticationInfo};
+ AuthenticationInfo, AuthParam, Algorithm, DigestResponse, Credentials};
fn is_mark(c: u8) -> bool {
c == b'-' || c == b'_' || c == b'.' || c == b'!' || c == b'~' || c == b'*' || c == b'\'' ||
tag!(b","),
ainfo)));
+named!(username<Vec<u8>>, preceded!(
+ tag!(b"username="),
+ quoted_string));
+
+named!(realm<Vec<u8>>, preceded!(
+ tag!(b"realm="),
+ quoted_string));
+
+named!(nonce<Vec<u8>>, preceded!(
+ tag!(b"nonce="),
+ quoted_string));
+
+named!(digest_uri<Vec<u8>>, preceded!(
+ tag!(b"digest_uri="),
+ quoted_string));
+
+named!(dresponse<Vec<u8>>, preceded!(
+ tag!(b"response="),
+ response_digest));
+
+named!(algorithm<Algorithm>, alt!(
+ tag!("MD5") => { |_| Algorithm::MD5 } |
+ tag!("MD5-sess") => { |_| Algorithm::MD5_sess } |
+ token => { |t| Algorithm::Token(t) }
+));
+
+named!(opaque<Vec<u8>>, preceded!(
+ tag!(b"opaque="),
+ quoted_string));
+
+named!(auth_param<AuthParam>, separated_pair!(
+ token,
+ tag!(b"="),
+ alt!(
+ token |
+ quoted_string)));
+
+named!(digest_response<Vec<DigestResponse>>, many1!(alt!(
+ username => { |u| DigestResponse::Username(u) } |
+ realm => { |r| DigestResponse::Realm(r) } |
+ nonce => { |n| DigestResponse::Nonce(n) } |
+ digest_uri => { |d| DigestResponse::DigestUri(d) } |
+ dresponse => { |d| DigestResponse::Response(d) } |
+ algorithm => { |a| DigestResponse::Algorithm(a) } |
+ cnonce => { |c| DigestResponse::Cnonce(c) } |
+ opaque => { |o| DigestResponse::Opaque(o) } |
+ message_qop => { |m| DigestResponse::MessageQop(m) } |
+ nonce_count => { |n| DigestResponse::NonceCount(n) } |
+ auth_param => { |(k, v)| DigestResponse::AuthParam(k, v) })));
+
+named!(other_response<(Vec<u8>, Vec<AuthParam>)>, separated_pair!(
+ token,
+ tag!(b" "),
+ separated_nonempty_list!(
+ tag!(b","),
+ auth_param)));
+
+named!(credentials<Credentials>, alt!(
+ preceded!(
+ tag!(b"Digest "),
+ digest_response) => { |d| Credentials::Digest(d) } |
+ other_response => { |(s,p)| Credentials::Other(s, p) }));
+
+named!(authorization_header<Credentials>, preceded!(
+ tag!(b"Authorization:"),
+ credentials));
+
named!(pub header<Header>, alt!(
// RFC 3261 Headers
accept_header => { |a| Header::Accept(a) } |
accept_language_header => { |a| Header::AcceptLanguage(a) } |
alert_info_header => { |a| Header::AlertInfo(a) } |
allow_header => { |a| Header::Allow(a) } |
- authentication_info_header => { |a| Header::AuthenticationInfo(a) }
+ authentication_info_header => { |a| Header::AuthenticationInfo(a) } |
+ authorization_header => { |a| Header::Authorization(a) }
));
NonceCount(Vec<u8>),
}
+pub type AuthParam = (Vec<u8>, Vec<u8>);
+
+#[derive(Debug)]
+pub enum Algorithm {
+ MD5,
+ MD5_sess,
+ Token(Vec<u8>),
+}
+
+#[derive(Debug)]
+pub enum DigestResponse {
+ Username(Vec<u8>),
+ Realm(Vec<u8>),
+ Nonce(Vec<u8>),
+ DigestUri(Vec<u8>),
+ Response(Vec<u8>),
+ Algorithm(Algorithm),
+ Cnonce(Vec<u8>),
+ Opaque(Vec<u8>),
+ MessageQop(Qop),
+ NonceCount(Vec<u8>),
+ AuthParam(Vec<u8>, Vec<u8>),
+}
+
+#[derive(Debug)]
+pub enum Credentials {
+ Digest(Vec<DigestResponse>),
+ Other(Vec<u8>, Vec<AuthParam>),
+}
+
#[derive(Debug)]
pub enum Header {
Accept(Vec<AcceptRange>),
AlertInfo(Vec<AlertParam>),
Allow(Vec<Method>),
AuthenticationInfo(Vec<AuthenticationInfo>),
+ Authorization(Credentials),
From(Uri),
To(Uri),
Extension { name: String, value: String },