Content lenght fix (#59)

* Send ServerStatus::WorkerFailed update if worker is failed

* Do not add content-length header for empty body #56
This commit is contained in:
Nikolay Kim 2021-09-27 20:21:04 +06:00 committed by GitHub
parent 87915f945a
commit b3fd4f6b2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 17 additions and 5 deletions

View file

@ -1,8 +1,14 @@
# Changes
## [0.4.1] - 2021-09-23
## [0.4.1] - 2021-09-27
* framed::Read::resume() returns true if it was resumed
* server: Send `ServerStatus::WorkerFailed` update if worker is failed
* server: Make `ServerBuilder::status_handler()` public
* framed: Read::resume() returns true if it was paused before
* http::client: Do not add content-length header for empty body #56
## [0.4.0] - 2021-09-17

View file

@ -1,6 +1,6 @@
[package]
name = "ntex"
version = "0.4.0"
version = "0.4.1"
authors = ["ntex contributors <team@ntex.rs>"]
description = "Framework for composable network services"
readme = "README.md"

View file

@ -232,7 +232,7 @@ impl RequestHeadType {
timeout: Millis,
config: &ClientConfig,
) -> SendClientRequest {
self.send_body(addr, response_decompress, timeout, config, Body::Empty)
self.send_body(addr, response_decompress, timeout, config, Body::None)
}
fn set_header_if_none<V>(

View file

@ -386,6 +386,7 @@ impl Accept {
match self.workers[self.next].send(msg) {
Ok(_) => (),
Err(tmp) => {
self.update_status(ServerStatus::WorkerFailed);
self.srv.worker_faulted(self.workers[self.next].idx);
msg = tmp;
self.workers.swap_remove(self.next);
@ -413,6 +414,7 @@ impl Accept {
}
Err(tmp) => {
trace!("Worker failed while processing connection");
self.update_status(ServerStatus::WorkerFailed);
self.srv.worker_faulted(self.workers[self.next].idx);
msg = tmp;
self.workers.swap_remove(self.next);

View file

@ -128,7 +128,6 @@ impl ServerBuilder {
self
}
#[doc(hidden)]
/// Set server status handler.
///
/// Server calls this handler on every inner status update.

View file

@ -33,10 +33,13 @@ pub use self::test::{build_test_server, test_server, TestServer};
#[doc(hidden)]
pub use self::socket::FromStream;
#[non_exhaustive]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
/// Server readiness status
pub enum ServerStatus {
Ready,
NotReady,
WorkerFailed,
}
/// Socket id token

View file

@ -247,6 +247,7 @@ mod tests {
assert!(second_time - first_time >= time::Duration::from_millis(wait_time));
}
#[cfg(not(target_os = "macos"))]
#[crate::rt_test]
async fn test_interval() {
let mut int = interval(Millis(250));
@ -272,6 +273,7 @@ mod tests {
);
}
#[cfg(not(target_os = "macos"))]
#[crate::rt_test]
async fn test_interval_one_sec() {
let int = interval(Millis::ONE_SEC);