♻️ Fix unwrap()s in ptth_core.
Some were in an unused function, so I removed that function. Some were in graceful_shutdown and can't really be handled. So I made them into "expect"smain
parent
5f9e84f7f6
commit
3e74f2b1ef
|
@ -25,7 +25,7 @@ pub fn init () -> oneshot::Receiver <()> {
|
|||
let tx = tx.replace (None);
|
||||
|
||||
if let Some (tx) = tx {
|
||||
tx.send (()).unwrap ();
|
||||
tx.send (()).expect ("Error sending Ctrl-C to program");
|
||||
}
|
||||
}).expect ("Error setting Ctrl-C handler");
|
||||
|
||||
|
@ -72,8 +72,8 @@ impl ForcedShutdown {
|
|||
server: F
|
||||
) -> Result <T, ShutdownError> {
|
||||
let fut = async move {
|
||||
self.rx.await.unwrap ();
|
||||
self.tx.send (()).unwrap ();
|
||||
self.rx.await.expect ("Error awaiting graceful shutdown signal");
|
||||
self.tx.send (()).expect ("Error forwarding graceful shutdown signal");
|
||||
let timeout = 5;
|
||||
debug! ("Starting graceful shutdown. Forcing shutdown in {} seconds", timeout);
|
||||
delay_for (Duration::from_secs (timeout)).await;
|
||||
|
|
|
@ -154,24 +154,6 @@ pub struct Response {
|
|||
}
|
||||
|
||||
impl Response {
|
||||
pub async fn into_bytes (self) -> Vec <u8> {
|
||||
let mut body = match self.body {
|
||||
None => return Vec::new (),
|
||||
Some (x) => x,
|
||||
};
|
||||
|
||||
let mut result = match self.content_length {
|
||||
None => Vec::new (),
|
||||
Some (x) => Vec::with_capacity (x.try_into ().unwrap ()),
|
||||
};
|
||||
|
||||
while let Some (Ok (mut chunk)) = body.recv ().await {
|
||||
result.append (&mut chunk);
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
pub fn status_code (&mut self, c: StatusCode) -> &mut Self {
|
||||
self.parts.status_code = c;
|
||||
self
|
||||
|
|
Loading…
Reference in New Issue