From 18a2fde154d1facb9e503bb34e302dfd62948751 Mon Sep 17 00:00:00 2001
From: Nikolay Kim
Date: Tue, 2 Nov 2021 19:30:33 +0600
Subject: [PATCH] h1: allow to override connection type in on-request handler
---
.github/workflows/linux.yml | 10 +++++-----
README.md | 4 ++--
ntex/CHANGES.md | 4 ++++
ntex/Cargo.toml | 2 +-
ntex/README.md | 4 ++--
ntex/src/http/h1/codec.rs | 4 ++++
ntex/src/http/h1/dispatcher.rs | 3 +++
7 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml
index 916f6e1f..5132bd29 100644
--- a/.github/workflows/linux.yml
+++ b/.github/workflows/linux.yml
@@ -8,7 +8,7 @@ jobs:
fail-fast: false
matrix:
version:
- - 1.51.0 # MSRV
+ - 1.53.0 # MSRV
- stable
- nightly
@@ -43,7 +43,7 @@ jobs:
key: ${{ matrix.version }}-x86_64-unknown-linux-gnu-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo tarpaulin
- if: matrix.version == '1.51.0' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
+ if: matrix.version == '1.53.0' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
uses: actions/cache@v1
with:
path: ~/.cargo/bin
@@ -57,19 +57,19 @@ jobs:
args: --all --all-features --no-fail-fast -- --nocapture
- name: Install tarpaulin
- if: matrix.version == '1.51.0' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
+ if: matrix.version == '1.53.0' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
continue-on-error: true
run: |
cargo install cargo-tarpaulin
- name: Generate coverage report
- if: matrix.version == '1.51.0' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
+ if: matrix.version == '1.53.0' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
continue-on-error: true
run: |
cargo tarpaulin --out Xml --all --all-features
- name: Upload to Codecov
- if: matrix.version == '1.51.0' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
+ if: matrix.version == '1.53.0' && (github.ref == 'refs/heads/master' || github.event_name == 'pull_request')
continue-on-error: true
uses: codecov/codecov-action@v1
with:
diff --git a/README.md b/README.md
index 35ccee5f..39d10de6 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@
[](https://codecov.io/gh/ntex-rs/ntex)
[](https://crates.io/crates/ntex)
[](https://docs.rs/ntex)
-[](https://blog.rust-lang.org/2021/03/25/Rust-1.51.0.html)
+[](https://blog.rust-lang.org/2021/06/17/Rust-1.53.0.html)

@@ -24,7 +24,7 @@
## Documentation & community resources
* [Documentation](https://docs.rs/ntex)
-* Minimum supported Rust version: 1.48 or later
+* Minimum supported Rust version: 1.53 or later
## License
diff --git a/ntex/CHANGES.md b/ntex/CHANGES.md
index a730e6a0..b50f876b 100644
--- a/ntex/CHANGES.md
+++ b/ntex/CHANGES.md
@@ -1,5 +1,9 @@
# Changes
+## [0.4.7] - 2021-11-02
+
+* h1: allow to override connection type in on-request handler
+
## [0.4.6] - 2021-10-29
* time: fix wheel time calculations
diff --git a/ntex/Cargo.toml b/ntex/Cargo.toml
index 409d296f..6da3aa5f 100644
--- a/ntex/Cargo.toml
+++ b/ntex/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "ntex"
-version = "0.4.6"
+version = "0.4.7"
authors = ["ntex contributors "]
description = "Framework for composable network services"
readme = "README.md"
diff --git a/ntex/README.md b/ntex/README.md
index 35ccee5f..39d10de6 100644
--- a/ntex/README.md
+++ b/ntex/README.md
@@ -7,7 +7,7 @@
[](https://codecov.io/gh/ntex-rs/ntex)
[](https://crates.io/crates/ntex)
[](https://docs.rs/ntex)
-[](https://blog.rust-lang.org/2021/03/25/Rust-1.51.0.html)
+[](https://blog.rust-lang.org/2021/06/17/Rust-1.53.0.html)

@@ -24,7 +24,7 @@
## Documentation & community resources
* [Documentation](https://docs.rs/ntex)
-* Minimum supported Rust version: 1.48 or later
+* Minimum supported Rust version: 1.53 or later
## License
diff --git a/ntex/src/http/h1/codec.rs b/ntex/src/http/h1/codec.rs
index a9c5b575..cf7b2dec 100644
--- a/ntex/src/http/h1/codec.rs
+++ b/ntex/src/http/h1/codec.rs
@@ -98,6 +98,10 @@ impl Codec {
self.flags.get().contains(Flags::KEEPALIVE_ENABLED)
}
+ pub(super) fn set_ctype(&self, ctype: ConnectionType) {
+ self.ctype.set(ctype)
+ }
+
#[inline]
#[doc(hidden)]
pub fn set_date_header(&self, dst: &mut BytesMut) {
diff --git a/ntex/src/http/h1/dispatcher.rs b/ntex/src/http/h1/dispatcher.rs
index 5de80e71..ebfbe1c5 100644
--- a/ntex/src/http/h1/dispatcher.rs
+++ b/ntex/src/http/h1/dispatcher.rs
@@ -241,6 +241,9 @@ where
if let Poll::Ready(result) = Pin::new(fut).poll(cx) {
match result {
Ok(req) => {
+ this.inner
+ .codec
+ .set_ctype(req.head().connection_type());
if req.head().expect() {
// Handle normal requests with EXPECT: 100-Continue` header
Some(CallState::Expect {