diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml
new file mode 100644
index 00000000..110244bb
--- /dev/null
+++ b/.github/workflows/checks.yml
@@ -0,0 +1,38 @@
+name: Checks
+
+on: [push, pull_request]
+
+jobs:
+ clippy:
+ name: Clippy
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions-rs/toolchain@v1
+ with:
+ toolchain: nightly
+ components: clippy
+ override: true
+ - uses: actions-rs/clippy-check@v1
+ with:
+ token: ${{ secrets.GITHUB_TOKEN }}
+ args: --all-features
+
+ fmt:
+ name: Rustfmt
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ rust:
+ - stable
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions-rs/toolchain@v1
+ with:
+ profile: minimal
+ toolchain: ${{ matrix.rust }}
+ override: true
+ - uses: actions-rs/cargo@v1
+ with:
+ command: fmt
+ args: --all -- --check
diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
index d451f017..f0080661 100644
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -48,6 +48,13 @@ jobs:
path: target
key: ${{ matrix.version }}-x86_64-unknown-linux-gnu-cargo-build-trimmed-${{ hashFiles('**/Cargo.lock') }}
+ - name: Cache cargo tarpaulin
+ if: matrix.version == 'stable' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
+ uses: actions/cache@v1
+ with:
+ path: ~/.cargo/bin/cargo-tarpaulin
+ key: ${{ matrix.version }}-x86_64-unknown-linux-gnu-tarpaulin
+
- name: check build
uses: actions-rs/cargo@v1
with:
diff --git a/README.md b/README.md
index e0b8873c..02d7c43f 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
This is personal project, please, do not use it
-[/badge.svg)](https://travis-ci.org/ntex-rs/ntex)
+/badge.svg)
[](https://codecov.io/gh/ntex-rs/ntex)
[](https://crates.io/crates/ntex)
[](https://docs.rs/ntex)
diff --git a/codecov.yml b/codecov.yml
index ca939e38..66ec69b4 100644
--- a/codecov.yml
+++ b/codecov.yml
@@ -2,6 +2,5 @@ ignore: # ignore codecoverage on following paths
- "**/tests"
- "**/benches"
- "**/examples"
- - "**/actix-net"
- - "actix-net"
- - "ntex-web-macros"
+ - "ntex-macros"
+ - "ntex-rt-macros"
diff --git a/ntex/src/http/h1/dispatcher.rs b/ntex/src/http/h1/dispatcher.rs
index 2036c7f3..5d73a4e5 100644
--- a/ntex/src/http/h1/dispatcher.rs
+++ b/ntex/src/http/h1/dispatcher.rs
@@ -256,7 +256,7 @@ where
}
// keep-alive book-keeping
- let _ = this.inner.poll_keepalive(cx, this.call.is_io())?;
+ this.inner.poll_keepalive(cx, this.call.is_io())?;
// shutdown process
if this.inner.flags.contains(Flags::SHUTDOWN) {
@@ -542,52 +542,46 @@ where
fn poll_write(&mut self, cx: &mut Context<'_>) -> Result {
let mut flushed = false;
- loop {
- if let Some(ref mut stream) = self.send_payload {
- // resize write buffer
- let len = self.write_buf.len();
- let remaining = self.write_buf.capacity() - len;
- if remaining < WRITE_LW_BUFFER_SIZE {
- self.write_buf.reserve(HW_BUFFER_SIZE - remaining);
- }
+ while let Some(ref mut stream) = self.send_payload {
+ // resize write buffer
+ let len = self.write_buf.len();
+ let remaining = self.write_buf.capacity() - len;
+ if remaining < WRITE_LW_BUFFER_SIZE {
+ self.write_buf.reserve(HW_BUFFER_SIZE - remaining);
+ }
- if len < HW_BUFFER_SIZE {
- match stream.poll_next_chunk(cx) {
- Poll::Ready(Some(Ok(item))) => {
- flushed = false;
- self.codec.encode(
- Message::Chunk(Some(item)),
- &mut self.write_buf,
- )?;
- }
- Poll::Ready(None) => {
- flushed = false;
- self.codec
- .encode(Message::Chunk(None), &mut self.write_buf)?;
- self.send_payload = None;
- break;
- }
- Poll::Ready(Some(Err(_))) => return Err(DispatchError::Unknown),
- Poll::Pending => {
- // response payload stream is not ready
- // we can only flush
- if !flushed {
- self.poll_flush(cx)?;
- }
- return Ok(PollWrite::Pending);
- }
+ if len < HW_BUFFER_SIZE {
+ match stream.poll_next_chunk(cx) {
+ Poll::Ready(Some(Ok(item))) => {
+ flushed = false;
+ self.codec
+ .encode(Message::Chunk(Some(item)), &mut self.write_buf)?;
}
- } else {
- // write buffer is full, try to flush and check if we have
- // space in buffer
- flushed = true;
- self.poll_flush(cx)?;
- if self.write_buf.len() >= HW_BUFFER_SIZE {
+ Poll::Ready(None) => {
+ flushed = false;
+ self.codec
+ .encode(Message::Chunk(None), &mut self.write_buf)?;
+ self.send_payload = None;
+ break;
+ }
+ Poll::Ready(Some(Err(_))) => return Err(DispatchError::Unknown),
+ Poll::Pending => {
+ // response payload stream is not ready
+ // we can only flush
+ if !flushed {
+ self.poll_flush(cx)?;
+ }
return Ok(PollWrite::Pending);
}
}
} else {
- break;
+ // write buffer is full, try to flush and check if we have
+ // space in buffer
+ flushed = true;
+ self.poll_flush(cx)?;
+ if self.write_buf.len() >= HW_BUFFER_SIZE {
+ return Ok(PollWrite::Pending);
+ }
}
}
@@ -657,7 +651,7 @@ where
}
if self.read_buf.is_empty() {
- return Ok(PollRead::NoUpdates);
+ Ok(PollRead::NoUpdates)
} else {
let result = self.input_decode();
diff --git a/ntex/src/http/service.rs b/ntex/src/http/service.rs
index d28e0645..fab92276 100644
--- a/ntex/src/http/service.rs
+++ b/ntex/src/http/service.rs
@@ -636,11 +636,7 @@ where
};
let (_, cfg, on_connect, peer_addr) = data.take().unwrap();
self.as_mut().project().state.set(State::H2(Dispatcher::new(
- cfg.clone(),
- conn,
- on_connect,
- None,
- peer_addr,
+ cfg, conn, on_connect, None, peer_addr,
)));
self.poll(cx)
}
diff --git a/ntex/tests/http_awc_client.rs b/ntex/tests/http_awc_client.rs
index 6c12f79b..64c6264f 100644
--- a/ntex/tests/http_awc_client.rs
+++ b/ntex/tests/http_awc_client.rs
@@ -220,7 +220,10 @@ async fn test_connection_force_close() {
assert!(response.status().is_success());
// req 2
- let req = client.post(srv.url("/")).force_close();
+ let req = client
+ .post(srv.url("/"))
+ .timeout(Duration::from_secs(10))
+ .force_close();
let response = req.send().await.unwrap();
assert!(response.status().is_success());