Move HttpProtocol to ntex-io

This commit is contained in:
Nikolay Kim 2022-02-18 15:31:16 +06:00
parent bd18c122b4
commit 706853c72b
16 changed files with 35 additions and 33 deletions

View file

@ -1,5 +1,7 @@
# Changes
* Add HttpProtocol type from ntex-tls
## [0.1.7] - 2022-01-30
* Use BytesVec type for buffers and Filter trait

View file

@ -1,6 +1,6 @@
[package]
name = "ntex-io"
version = "0.1.7"
version = "0.1.8"
authors = ["ntex contributors <team@ntex.rs>"]
description = "Utilities for encoding and decoding frames"
keywords = ["network", "framework", "async", "futures"]
@ -17,8 +17,8 @@ path = "src/lib.rs"
[dependencies]
ntex-codec = "0.6.2"
ntex-bytes = "0.1.11"
ntex-util = "0.1.13"
ntex-bytes = "0.1.14"
ntex-util = "0.1.15"
ntex-service = "0.3.1"
bitflags = "1.3"

View file

@ -22,6 +22,14 @@ impl fmt::Debug for PeerAddr {
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
/// Http protocol definition
pub enum HttpProtocol {
Http1,
Http2,
Unknown,
}
pub struct QueryItem<T> {
item: Option<Box<dyn any::Any>>,
_t: PhantomData<T>,

View file

@ -1,5 +1,7 @@
# Changes
* Move HttpProtocol to ntex-io
## [0.1.4] - 2022-02-11
* Do not use SslRef::is_init_finished() method for openssl

View file

@ -1,6 +1,6 @@
[package]
name = "ntex-tls"
version = "0.1.4"
version = "0.1.5"
authors = ["ntex contributors <team@ntex.rs>"]
description = "An implementation of SSL streams for ntex backed by OpenSSL"
keywords = ["network", "framework", "async", "futures"]
@ -26,8 +26,8 @@ rustls = ["tls_rust"]
[dependencies]
ntex-bytes = "0.1.14"
ntex-io = "0.1.7"
ntex-util = "0.1.13"
ntex-io = "0.1.8"
ntex-util = "0.1.15"
ntex-service = "0.3.1"
pin-project-lite = "0.2"

View file

@ -1,6 +1,8 @@
//! An implementations of SSL streams for ntex ecosystem
use std::sync::atomic::{AtomicUsize, Ordering};
#[doc(hidden)]
#[deprecated]
pub mod types;
#[cfg(feature = "openssl")]

View file

@ -6,7 +6,7 @@ use std::{
};
use ntex_bytes::{BufMut, BytesVec, PoolRef};
use ntex_io::{Base, Filter, FilterFactory, Io, IoRef, ReadStatus, WriteStatus};
use ntex_io::{types, Base, Filter, FilterFactory, Io, IoRef, ReadStatus, WriteStatus};
use ntex_util::{future::poll_fn, ready, time, time::Millis};
use tls_openssl::ssl::{self, SslStream};
use tls_openssl::x509::X509;
@ -14,8 +14,6 @@ use tls_openssl::x509::X509;
mod accept;
pub use self::accept::{Acceptor, AcceptorService};
use super::types;
/// Connection's peer cert
#[derive(Debug)]
pub struct PeerCert(pub X509);

View file

@ -3,12 +3,11 @@ use std::io::{self, Read as IoRead, Write as IoWrite};
use std::{any, cell::Cell, cell::RefCell, sync::Arc, task::Context, task::Poll};
use ntex_bytes::{BufMut, BytesVec};
use ntex_io::{Filter, Io, IoRef, ReadStatus, WriteStatus};
use ntex_io::{types, Filter, Io, IoRef, ReadStatus, WriteStatus};
use ntex_util::{future::poll_fn, ready};
use tls_rust::{ClientConfig, ClientConnection, ServerName};
use crate::rustls::{IoInner, TlsFilter, Wrapper};
use crate::types;
use super::{PeerCert, PeerCertChain};

View file

@ -3,12 +3,11 @@ use std::io::{self, Read as IoRead, Write as IoWrite};
use std::{any, cell::Cell, cell::RefCell, sync::Arc, task::Context, task::Poll};
use ntex_bytes::{BufMut, BytesVec};
use ntex_io::{Filter, Io, IoRef, ReadStatus, WriteStatus};
use ntex_io::{types, Filter, Io, IoRef, ReadStatus, WriteStatus};
use ntex_util::{future::poll_fn, ready, time, time::Millis};
use tls_rust::{ServerConfig, ServerConnection};
use crate::rustls::{IoInner, TlsFilter, Wrapper};
use crate::types;
use super::{PeerCert, PeerCertChain};

View file

@ -1,6 +1 @@
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub enum HttpProtocol {
Http1,
Http2,
Unknown,
}
pub use ntex_io::types::HttpProtocol;

View file

@ -1,6 +1,6 @@
[package]
name = "ntex"
version = "0.5.15"
version = "0.5.16"
authors = ["ntex contributors <team@ntex.rs>"]
description = "Framework for composable network services"
readme = "README.md"
@ -54,9 +54,9 @@ ntex-service = "0.3.1"
ntex-macros = "0.1.3"
ntex-util = "0.1.15"
ntex-bytes = "0.1.14"
ntex-tls = "0.1.4"
ntex-rt = "0.4.3"
ntex-io = "0.1.7"
ntex-io = "0.1.8"
ntex-tls = "0.1.5"
ntex-tokio = "0.1.3"
ntex-glommio = { version = "0.1.1", optional = true }
ntex-async-std = { version = "0.1.1", optional = true }

View file

@ -1,12 +1,11 @@
use std::{cell::RefCell, fmt, rc::Rc, time};
use h2::client::SendRequest;
use ntex_tls::types::HttpProtocol;
use crate::http::body::MessageBody;
use crate::http::message::{RequestHeadType, ResponseHead};
use crate::http::payload::Payload;
use crate::io::IoBoxed;
use crate::io::{types::HttpProtocol, IoBoxed};
use crate::util::Bytes;
use super::error::SendRequestError;

View file

@ -4,9 +4,8 @@ use std::{cell::RefCell, collections::VecDeque, future::Future, pin::Pin, rc::Rc
use h2::client::{Builder, Connection as H2Connection, SendRequest};
use http::uri::Authority;
use ntex_tls::types::HttpProtocol;
use crate::io::{IoBoxed, TokioIoBoxed};
use crate::io::{types::HttpProtocol, IoBoxed, TokioIoBoxed};
use crate::time::{now, Millis};
use crate::util::{ready, Bytes, HashMap, HashSet};
use crate::{channel::pool, rt::spawn, service::Service, task::LocalWaker};

View file

@ -33,8 +33,8 @@ pub use self::payload::{Payload, PayloadStream};
pub use self::request::Request;
pub use self::response::{Response, ResponseBuilder};
pub use self::service::HttpService;
pub use crate::io::types::HttpProtocol;
// re-exports
pub use http::uri::{self, Uri};
pub use http::{Method, StatusCode, Version};
pub use ntex_tls::types::HttpProtocol;

View file

@ -2,7 +2,6 @@ use std::task::{Context, Poll};
use std::{cell, error, fmt, future, marker, pin::Pin, rc::Rc};
use h2::server::{self, Handshake};
use ntex_tls::types::HttpProtocol;
use crate::io::{types, Filter, Io, IoRef, TokioIoBoxed};
use crate::service::{IntoServiceFactory, Service, ServiceFactory};
@ -376,7 +375,7 @@ where
io.query::<types::PeerAddr>().get()
);
if io.query::<HttpProtocol>().get() == Some(HttpProtocol::Http2) {
if io.query::<types::HttpProtocol>().get() == Some(types::HttpProtocol::Http2) {
io.set_disconnect_timeout(self.config.client_disconnect.into());
HttpServiceHandlerResponse {
state: ResponseState::H2Handshake {

View file

@ -70,8 +70,8 @@ mod danger {
#[cfg(feature = "openssl")]
#[ntex::test]
async fn test_openssl_string() {
use ntex::server::openssl;
use ntex_tls::{openssl::PeerCert, openssl::PeerCertChain, types::HttpProtocol};
use ntex::{io::types::HttpProtocol, server::openssl};
use ntex_tls::{openssl::PeerCert, openssl::PeerCertChain};
use tls_openssl::{
ssl::{SslConnector, SslMethod, SslVerifyMode},
x509::X509,
@ -154,8 +154,8 @@ async fn test_openssl_read_before_error() {
#[cfg(feature = "rustls")]
#[ntex::test]
async fn test_rustls_string() {
use ntex::server::rustls;
use ntex_tls::{rustls::PeerCert, rustls::PeerCertChain, types::HttpProtocol};
use ntex::{io::types::HttpProtocol, server::rustls};
use ntex_tls::{rustls::PeerCert, rustls::PeerCertChain};
use rustls_pemfile::certs;
use std::fs::File;
use std::io::BufReader;