aboutsummaryrefslogtreecommitdiff
path: root/src/encoding
diff options
context:
space:
mode:
Diffstat (limited to 'src/encoding')
-rw-r--r--src/encoding/headermap.rs2
-rw-r--r--src/encoding/headers.rs31
-rw-r--r--src/encoding/method.rs6
-rw-r--r--src/encoding/request.rs2
-rw-r--r--src/encoding/uri.rs2
5 files changed, 37 insertions, 6 deletions
diff --git a/src/encoding/headermap.rs b/src/encoding/headermap.rs
index 2f9f097..65ef8d2 100644
--- a/src/encoding/headermap.rs
+++ b/src/encoding/headermap.rs
@@ -2,7 +2,7 @@ use super::headers::Header;
use anyhow::Result;
use std::fmt::Display;
-#[derive(Debug)]
+#[derive(Debug, Clone)]
pub struct HeaderMap(pub Vec<(String, String)>);
impl HeaderMap {
diff --git a/src/encoding/headers.rs b/src/encoding/headers.rs
index 6bffc7e..e9196d1 100644
--- a/src/encoding/headers.rs
+++ b/src/encoding/headers.rs
@@ -103,3 +103,34 @@ impl FromStr for WWWAuthenticate {
})
}
}
+
+#[derive(Debug)]
+pub struct Authorization {
+ pub username: String,
+ pub realm: String,
+ pub nonce: String,
+ pub response: String,
+}
+impl Header for Authorization {
+ const NAME: &'static str = "Authorization";
+}
+impl Display for Authorization {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ let Self {
+ username,
+ realm,
+ nonce,
+ response,
+ } = self;
+ write!(
+ f,
+ "Digest username={username:?} realm={realm:?}, nonce={nonce:?}, response={response:?}"
+ )
+ }
+}
+impl FromStr for Authorization {
+ type Err = anyhow::Error;
+ fn from_str(_s: &str) -> Result<Self, Self::Err> {
+ todo!()
+ }
+}
diff --git a/src/encoding/method.rs b/src/encoding/method.rs
index 73829b0..6d38cab 100644
--- a/src/encoding/method.rs
+++ b/src/encoding/method.rs
@@ -6,7 +6,7 @@ pub enum Method {
Register,
Invite,
Ack,
- Option,
+ Options,
Cancel,
Bye,
}
@@ -17,7 +17,7 @@ impl Display for Method {
Method::Register => "REGISTER",
Method::Invite => "INVITE",
Method::Ack => "ACK",
- Method::Option => "OPTION",
+ Method::Options => "OPTIONS",
Method::Cancel => "CANCEL",
Method::Bye => "BYE",
})
@@ -30,7 +30,7 @@ impl FromStr for Method {
"REGISTER" => Method::Register,
"INVITE" => Method::Invite,
"ACK" => Method::Ack,
- "OPTION" => Method::Option,
+ "OPTIONS" => Method::Options,
"CANCEL" => Method::Cancel,
"BYE" => Method::Bye,
_ => bail!("unknown method"),
diff --git a/src/encoding/request.rs b/src/encoding/request.rs
index 124522c..aecd006 100644
--- a/src/encoding/request.rs
+++ b/src/encoding/request.rs
@@ -1,7 +1,7 @@
use super::{headermap::HeaderMap, method::Method, uri::Uri};
use std::fmt::Display;
-#[derive(Debug)]
+#[derive(Debug, Clone)]
pub struct Request {
pub method: Method,
pub uri: Uri,
diff --git a/src/encoding/uri.rs b/src/encoding/uri.rs
index 64572ba..7aeefdb 100644
--- a/src/encoding/uri.rs
+++ b/src/encoding/uri.rs
@@ -1,6 +1,6 @@
use std::fmt::Display;
-#[derive(Debug)]
+#[derive(Debug,Clone)]
pub struct Uri {
pub content: String,
}