Skip to content

Commit 4cfcb88

Browse files
Fix embedded-svc
1 parent 5758f29 commit 4cfcb88

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

edge-http/src/io/server.rs

+3-8
Original file line numberDiff line numberDiff line change
@@ -871,7 +871,7 @@ mod embedded_svc_compat {
871871
message: Option<&str>,
872872
headers: &[(&str, &str)],
873873
) -> Result<(), Self::Error> {
874-
super::Connection::initiate_response(self, status, message, headers).await
874+
super::Connection::initiate_response(self, status, message.unwrap_or(""), headers).await
875875
}
876876

877877
fn is_response_initiated(&self) -> bool {
@@ -896,7 +896,7 @@ mod embedded_svc_compat {
896896
&self,
897897
connection: &mut super::Connection<'b, T, N>,
898898
) -> Result<(), Self::Error> {
899-
connection.initiate_response(404, None, &[]).await
899+
connection.initiate_response(404, "", &[]).await
900900
}
901901
}
902902

@@ -916,12 +916,7 @@ mod embedded_svc_compat {
916916
let headers = connection.headers().ok();
917917

918918
if let Some(headers) = headers {
919-
if headers.path.map(|path| self.path == path).unwrap_or(false)
920-
&& headers
921-
.method
922-
.map(|method| self.method == method.into())
923-
.unwrap_or(false)
924-
{
919+
if headers.path == self.path && headers.method == self.method.into() {
925920
return self.handler.handle(connection).await;
926921
}
927922
}

edge-http/src/lib.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -1377,11 +1377,11 @@ mod embedded_svc_compat {
13771377

13781378
impl<'b, const N: usize> embedded_svc::http::Query for super::RequestHeaders<'b, N> {
13791379
fn uri(&self) -> &'_ str {
1380-
self.path.unwrap_or("")
1380+
self.path
13811381
}
13821382

13831383
fn method(&self) -> Method {
1384-
self.method.unwrap_or(super::Method::Get).into()
1384+
self.method.into()
13851385
}
13861386
}
13871387

@@ -1393,11 +1393,15 @@ mod embedded_svc_compat {
13931393

13941394
impl<'b, const N: usize> embedded_svc::http::Status for super::ResponseHeaders<'b, N> {
13951395
fn status(&self) -> u16 {
1396-
self.code.unwrap_or(200)
1396+
self.code
13971397
}
13981398

13991399
fn status_message(&self) -> Option<&'_ str> {
1400-
self.reason
1400+
if self.reason != "" {
1401+
Some(self.reason)
1402+
} else {
1403+
None
1404+
}
14011405
}
14021406
}
14031407

0 commit comments

Comments
 (0)