mirror of
https://github.com/ntex-rs/ntex.git
synced 2025-04-03 21:07:39 +03:00
do not use bytes directly
This commit is contained in:
parent
5f2f65e403
commit
f577c2acf3
59 changed files with 103 additions and 186 deletions
|
@ -1,11 +1,11 @@
|
|||
use std::{env, io};
|
||||
|
||||
use bytes::BytesMut;
|
||||
use futures::StreamExt;
|
||||
use log::info;
|
||||
use ntex::http::header::HeaderValue;
|
||||
use ntex::http::{HttpService, Request, Response};
|
||||
use ntex::server::Server;
|
||||
use ntex::util::BytesMut;
|
||||
|
||||
#[ntex::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use std::{env, io};
|
||||
|
||||
use bytes::BytesMut;
|
||||
use futures::StreamExt;
|
||||
use log::info;
|
||||
use ntex::http::header::HeaderValue;
|
||||
use ntex::http::{HttpService, Request, Response};
|
||||
use ntex::server::Server;
|
||||
use ntex::util::BytesMut;
|
||||
|
||||
async fn handle_request(mut req: Request) -> Result<Response, io::Error> {
|
||||
let mut body = BytesMut::new();
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
//! Framed transport dispatcher
|
||||
use std::task::{Context, Poll};
|
||||
use std::{
|
||||
cell::Cell, cell::RefCell, future::Future, pin::Pin, rc::Rc, time::Duration,
|
||||
time::Instant,
|
||||
cell::Cell, cell::RefCell, future::Future, pin::Pin, rc::Rc, task::Context,
|
||||
task::Poll, time::Duration, time::Instant,
|
||||
};
|
||||
|
||||
use crate::codec::{AsyncRead, AsyncWrite, Decoder, Encoder};
|
||||
|
@ -506,13 +505,13 @@ where
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use bytes::Bytes;
|
||||
use rand::Rng;
|
||||
use std::sync::{atomic::AtomicBool, atomic::Ordering::Relaxed, Arc, Mutex};
|
||||
|
||||
use crate::codec::BytesCodec;
|
||||
use crate::rt::time::sleep;
|
||||
use crate::testing::Io;
|
||||
use crate::util::Bytes;
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
|
@ -1045,10 +1045,8 @@ impl Drop for OnDisconnect {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use bytes::Bytes;
|
||||
|
||||
use super::*;
|
||||
use crate::{codec::BytesCodec, testing::Io, util::lazy};
|
||||
use crate::{codec::BytesCodec, testing::Io, util::lazy, util::Bytes};
|
||||
|
||||
const BIN: &[u8] = b"GET /test HTTP/1\r\n\r\n";
|
||||
const TEXT: &str = "GET /test HTTP/1\r\n\r\n";
|
||||
|
|
|
@ -2,8 +2,7 @@ use std::{
|
|||
error::Error, fmt, marker::PhantomData, mem, pin::Pin, task::Context, task::Poll,
|
||||
};
|
||||
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use futures_core::Stream;
|
||||
use crate::{util::Bytes, util::BytesMut, Stream};
|
||||
|
||||
#[derive(Debug, PartialEq, Copy, Clone)]
|
||||
/// Body size hint
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use std::{fmt, future::Future, pin::Pin, time};
|
||||
|
||||
use bytes::Bytes;
|
||||
use h2::client::SendRequest;
|
||||
|
||||
use crate::codec::{AsyncRead, AsyncWrite, Framed};
|
||||
|
@ -9,7 +8,7 @@ use crate::http::h1::ClientCodec;
|
|||
use crate::http::message::{RequestHeadType, ResponseHead};
|
||||
use crate::http::payload::Payload;
|
||||
use crate::http::Protocol;
|
||||
use crate::util::{Either, Ready};
|
||||
use crate::util::{Bytes, Either, Ready};
|
||||
|
||||
use super::error::SendRequestError;
|
||||
use super::pool::Acquired;
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
use std::{convert::TryFrom, error::Error, fmt, net, rc::Rc, time::Duration};
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures_core::Stream;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::http::body::Body;
|
||||
use crate::http::error::HttpError;
|
||||
use crate::http::header::{self, HeaderMap, HeaderName, HeaderValue};
|
||||
use crate::http::{Method, RequestHead, RequestHeadType, Uri};
|
||||
use crate::{util::Bytes, Stream};
|
||||
|
||||
use super::sender::SendClientRequest;
|
||||
use super::ClientConfig;
|
||||
|
@ -54,7 +51,7 @@ impl FrozenClientRequest {
|
|||
}
|
||||
|
||||
/// Send a json body.
|
||||
pub fn send_json<T: Serialize>(&self, value: &T) -> SendClientRequest {
|
||||
pub fn send_json<T: serde::Serialize>(&self, value: &T) -> SendClientRequest {
|
||||
RequestHeadType::Rc(self.head.clone(), None).send_json(
|
||||
self.addr,
|
||||
self.response_decompress,
|
||||
|
@ -65,7 +62,7 @@ impl FrozenClientRequest {
|
|||
}
|
||||
|
||||
/// Send an urlencoded body.
|
||||
pub fn send_form<T: Serialize>(&self, value: &T) -> SendClientRequest {
|
||||
pub fn send_form<T: serde::Serialize>(&self, value: &T) -> SendClientRequest {
|
||||
RequestHeadType::Rc(self.head.clone(), None).send_form(
|
||||
self.addr,
|
||||
self.response_decompress,
|
||||
|
@ -190,7 +187,7 @@ impl FrozenSendBuilder {
|
|||
}
|
||||
|
||||
/// Complete request construction and send a json body.
|
||||
pub fn send_json<T: Serialize>(self, value: &T) -> SendClientRequest {
|
||||
pub fn send_json<T: serde::Serialize>(self, value: &T) -> SendClientRequest {
|
||||
if let Some(e) = self.err {
|
||||
return e.into();
|
||||
}
|
||||
|
@ -205,7 +202,7 @@ impl FrozenSendBuilder {
|
|||
}
|
||||
|
||||
/// Complete request construction and send an urlencoded body.
|
||||
pub fn send_form<T: Serialize>(self, value: &T) -> SendClientRequest {
|
||||
pub fn send_form<T: serde::Serialize>(self, value: &T) -> SendClientRequest {
|
||||
if let Some(e) = self.err {
|
||||
return e.into();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
use std::{io, io::Write, pin::Pin, task::Context, task::Poll, time};
|
||||
|
||||
use bytes::{BufMut, Bytes, BytesMut};
|
||||
|
||||
use crate::codec::{AsyncRead, AsyncWrite, Framed, ReadBuf};
|
||||
use crate::http::body::{BodySize, MessageBody};
|
||||
use crate::http::error::PayloadError;
|
||||
|
@ -9,7 +7,7 @@ use crate::http::h1;
|
|||
use crate::http::header::{HeaderMap, HeaderValue, HOST};
|
||||
use crate::http::message::{RequestHeadType, ResponseHead};
|
||||
use crate::http::payload::{Payload, PayloadStream};
|
||||
use crate::util::{next, poll_fn, send};
|
||||
use crate::util::{next, poll_fn, send, BufMut, Bytes, BytesMut};
|
||||
use crate::{Sink, Stream};
|
||||
|
||||
use super::connection::{ConnectionLifetime, ConnectionType, IoConnection};
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use std::{convert::TryFrom, time};
|
||||
|
||||
use bytes::Bytes;
|
||||
use h2::{client::SendRequest, SendStream};
|
||||
use http::header::{HeaderValue, CONNECTION, CONTENT_LENGTH, TRANSFER_ENCODING};
|
||||
use http::{request::Request, Method, Version};
|
||||
|
@ -10,7 +9,7 @@ use crate::http::body::{BodySize, MessageBody};
|
|||
use crate::http::header::HeaderMap;
|
||||
use crate::http::message::{RequestHeadType, ResponseHead};
|
||||
use crate::http::payload::Payload;
|
||||
use crate::util::poll_fn;
|
||||
use crate::util::{poll_fn, Bytes};
|
||||
|
||||
use super::connection::{ConnectionType, IoConnection};
|
||||
use super::error::SendRequestError;
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
use std::{convert::TryFrom, error::Error, fmt, net, rc::Rc, time::Duration};
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures_core::Stream;
|
||||
use serde::Serialize;
|
||||
|
||||
#[cfg(feature = "cookie")]
|
||||
use coo_kie::{Cookie, CookieJar};
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::http::body::Body;
|
||||
use crate::http::error::HttpError;
|
||||
|
@ -13,6 +10,7 @@ use crate::http::header::{self, HeaderMap, HeaderName, HeaderValue};
|
|||
use crate::http::{
|
||||
uri, ConnectionType, Method, RequestHead, RequestHeadType, Uri, Version,
|
||||
};
|
||||
use crate::{util::Bytes, Stream};
|
||||
|
||||
use super::error::{FreezeRequestError, InvalidUrl};
|
||||
use super::frozen::FrozenClientRequest;
|
||||
|
|
|
@ -2,8 +2,6 @@ use std::cell::{Ref, RefMut};
|
|||
use std::task::{Context, Poll};
|
||||
use std::{fmt, future::Future, marker::PhantomData, mem, pin::Pin};
|
||||
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use futures_core::Stream;
|
||||
use serde::de::DeserializeOwned;
|
||||
|
||||
#[cfg(feature = "cookie")]
|
||||
|
@ -13,7 +11,8 @@ use crate::http::error::PayloadError;
|
|||
use crate::http::header::{AsName, HeaderValue, CONTENT_LENGTH};
|
||||
use crate::http::{HeaderMap, StatusCode, Version};
|
||||
use crate::http::{HttpMessage, Payload, ResponseHead};
|
||||
use crate::util::Extensions;
|
||||
use crate::util::{Bytes, BytesMut, Extensions};
|
||||
use crate::Stream;
|
||||
|
||||
use super::error::JsonPayloadError;
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
use std::task::{Context, Poll};
|
||||
use std::{convert::TryFrom, error::Error, future::Future, net, pin::Pin, time};
|
||||
|
||||
use bytes::Bytes;
|
||||
use derive_more::From;
|
||||
use futures_core::Stream;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::http::body::{Body, BodyStream};
|
||||
|
@ -11,6 +8,7 @@ use crate::http::error::HttpError;
|
|||
use crate::http::header::{self, HeaderMap, HeaderName, HeaderValue};
|
||||
use crate::http::RequestHeadType;
|
||||
use crate::rt::time::{sleep, Sleep};
|
||||
use crate::{util::Bytes, Stream};
|
||||
|
||||
#[cfg(feature = "compress")]
|
||||
use crate::http::encoding::Decoder;
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
//! Test helpers for ntex http client to use during testing.
|
||||
use std::convert::TryFrom;
|
||||
|
||||
use bytes::Bytes;
|
||||
|
||||
#[cfg(feature = "cookie")]
|
||||
use coo_kie::{Cookie, CookieJar};
|
||||
|
||||
use crate::http::error::HttpError;
|
||||
use crate::http::header::{HeaderName, HeaderValue};
|
||||
use crate::http::{h1, Payload, ResponseHead, StatusCode, Version};
|
||||
use crate::util::Bytes;
|
||||
|
||||
use super::ClientResponse;
|
||||
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
use std::{future::Future, io, io::Write, pin::Pin, task::Context, task::Poll};
|
||||
|
||||
use brotli2::write::BrotliDecoder;
|
||||
use bytes::Bytes;
|
||||
use flate2::write::{GzDecoder, ZlibDecoder};
|
||||
use futures_core::Stream;
|
||||
|
||||
use super::Writer;
|
||||
use crate::http::error::PayloadError;
|
||||
use crate::http::header::{ContentEncoding, HeaderMap, CONTENT_ENCODING};
|
||||
use crate::rt::task::{spawn_blocking, JoinHandle};
|
||||
use crate::{util::Bytes, Stream};
|
||||
|
||||
const INPLACE: usize = 2049;
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
use std::{future::Future, io, io::Write, pin::Pin, task::Context, task::Poll};
|
||||
|
||||
use brotli2::write::BrotliEncoder;
|
||||
use bytes::Bytes;
|
||||
use flate2::write::{GzEncoder, ZlibEncoder};
|
||||
|
||||
use crate::http::body::{Body, BodySize, MessageBody, ResponseBody};
|
||||
use crate::http::header::{ContentEncoding, HeaderValue, CONTENT_ENCODING};
|
||||
use crate::http::{ResponseHead, StatusCode};
|
||||
use crate::rt::task::{spawn_blocking, JoinHandle};
|
||||
use crate::util::Bytes;
|
||||
|
||||
use super::Writer;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
//! Content-Encoding support
|
||||
use std::io;
|
||||
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use crate::util::{Bytes, BytesMut};
|
||||
|
||||
mod decoder;
|
||||
mod encoder;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use std::{cell::Cell, cell::RefCell, io};
|
||||
|
||||
use bitflags::bitflags;
|
||||
use bytes::{Bytes, BytesMut};
|
||||
|
||||
use crate::codec::{Decoder, Encoder};
|
||||
use crate::http::body::BodySize;
|
||||
|
@ -9,6 +8,7 @@ use crate::http::config::DateService;
|
|||
use crate::http::error::{ParseError, PayloadError};
|
||||
use crate::http::message::{ConnectionType, RequestHeadType, ResponseHead};
|
||||
use crate::http::{Method, Version};
|
||||
use crate::util::{Bytes, BytesMut};
|
||||
|
||||
use super::decoder::{PayloadDecoder, PayloadItem, PayloadType};
|
||||
use super::{decoder, encoder, reserve_readbuf, Message, MessageType};
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
use std::{cell::Cell, fmt, io};
|
||||
|
||||
use bitflags::bitflags;
|
||||
use bytes::BytesMut;
|
||||
use http::{Method, Version};
|
||||
|
||||
use crate::codec::{Decoder, Encoder};
|
||||
use crate::http::body::BodySize;
|
||||
|
@ -11,6 +9,8 @@ use crate::http::error::ParseError;
|
|||
use crate::http::message::ConnectionType;
|
||||
use crate::http::request::Request;
|
||||
use crate::http::response::Response;
|
||||
use crate::http::{Method, Version};
|
||||
use crate::util::BytesMut;
|
||||
|
||||
use super::{decoder, decoder::PayloadType, encoder, Message};
|
||||
|
||||
|
@ -182,10 +182,9 @@ impl Encoder for Codec {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use bytes::{Bytes, BytesMut};
|
||||
|
||||
use super::*;
|
||||
use crate::http::{h1::PayloadItem, HttpMessage, Method};
|
||||
use crate::util::{Bytes, BytesMut};
|
||||
|
||||
#[test]
|
||||
fn test_http_request_chunked_payload_and_next_message() {
|
||||
|
|
|
@ -2,7 +2,6 @@ use std::{
|
|||
cell::Cell, convert::TryFrom, marker::PhantomData, mem::MaybeUninit, task::Poll,
|
||||
};
|
||||
|
||||
use bytes::{Buf, Bytes, BytesMut};
|
||||
use http::header::{HeaderName, HeaderValue};
|
||||
use http::{header, Method, StatusCode, Uri, Version};
|
||||
|
||||
|
@ -11,6 +10,7 @@ use crate::http::error::ParseError;
|
|||
use crate::http::header::HeaderMap;
|
||||
use crate::http::message::{ConnectionType, ResponseHead};
|
||||
use crate::http::request::Request;
|
||||
use crate::util::{Buf, Bytes, BytesMut};
|
||||
|
||||
use super::MAX_BUFFER_SIZE;
|
||||
|
||||
|
@ -641,12 +641,11 @@ impl ChunkedState {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use bytes::{Bytes, BytesMut};
|
||||
|
||||
use super::*;
|
||||
use crate::http::error::ParseError;
|
||||
use crate::http::header::{HeaderName, SET_COOKIE};
|
||||
use crate::http::{HttpMessage, Method, Version};
|
||||
use crate::util::{Bytes, BytesMut};
|
||||
|
||||
impl PayloadType {
|
||||
fn unwrap(self) -> PayloadDecoder {
|
||||
|
|
|
@ -5,11 +5,10 @@ use std::{
|
|||
time,
|
||||
};
|
||||
|
||||
use bytes::Bytes;
|
||||
|
||||
use crate::codec::{AsyncRead, AsyncWrite};
|
||||
use crate::framed::{ReadTask, State as IoState, WriteTask};
|
||||
use crate::service::Service;
|
||||
use crate::util::Bytes;
|
||||
|
||||
use crate::http;
|
||||
use crate::http::body::{BodySize, MessageBody, ResponseBody};
|
||||
|
@ -733,7 +732,6 @@ mod tests {
|
|||
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||
use std::{cell::Cell, io, sync::Arc};
|
||||
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use rand::Rng;
|
||||
|
||||
use super::*;
|
||||
|
@ -741,7 +739,8 @@ mod tests {
|
|||
use crate::http::h1::{ClientCodec, ExpectHandler, UpgradeHandler};
|
||||
use crate::http::{body, Request, ResponseHead, StatusCode};
|
||||
use crate::service::{boxed, fn_service, IntoService};
|
||||
use crate::{codec::Decoder, rt::time::sleep, testing::Io, util::lazy, util::next};
|
||||
use crate::util::{lazy, next, Bytes, BytesMut};
|
||||
use crate::{codec::Decoder, rt::time::sleep, testing::Io};
|
||||
|
||||
const BUFFER_SIZE: usize = 32_768;
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
use std::io::Write;
|
||||
use std::marker::PhantomData;
|
||||
use std::{cell::Cell, cmp, io, mem, ptr, ptr::copy_nonoverlapping, slice};
|
||||
|
||||
use bytes::{BufMut, BytesMut};
|
||||
use std::{cell::Cell, cmp, io, io::Write, mem, ptr, ptr::copy_nonoverlapping, slice};
|
||||
|
||||
use crate::http::body::BodySize;
|
||||
use crate::http::config::DateService;
|
||||
|
@ -11,6 +8,7 @@ use crate::http::helpers;
|
|||
use crate::http::message::{ConnectionType, RequestHeadType};
|
||||
use crate::http::response::Response;
|
||||
use crate::http::{HeaderMap, StatusCode, Version};
|
||||
use crate::util::{BufMut, BytesMut};
|
||||
|
||||
const AVERAGE_HEADER_SIZE: usize = 30;
|
||||
|
||||
|
@ -595,11 +593,10 @@ unsafe fn convert_usize(mut n: u64, bytes: &mut BytesMut) {
|
|||
mod tests {
|
||||
use std::rc::Rc;
|
||||
|
||||
use bytes::Bytes;
|
||||
|
||||
use super::*;
|
||||
use crate::http::header::{HeaderValue, AUTHORIZATION};
|
||||
use crate::http::RequestHead;
|
||||
use crate::util::Bytes;
|
||||
|
||||
#[test]
|
||||
fn test_chunked_te() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//! HTTP/1 implementation
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use crate::util::{Bytes, BytesMut};
|
||||
|
||||
mod client;
|
||||
mod codec;
|
||||
|
|
|
@ -3,11 +3,8 @@ use std::rc::{Rc, Weak};
|
|||
use std::task::{Context, Poll};
|
||||
use std::{cell::RefCell, collections::VecDeque, pin::Pin};
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures_core::Stream;
|
||||
|
||||
use crate::http::error::PayloadError;
|
||||
use crate::task::LocalWaker;
|
||||
use crate::{task::LocalWaker, util::Bytes, Stream};
|
||||
|
||||
/// max buffer size 32k
|
||||
const MAX_BUFFER_SIZE: usize = 32_768;
|
||||
|
|
|
@ -3,7 +3,6 @@ use std::{
|
|||
convert::TryFrom, future::Future, marker::PhantomData, net, pin::Pin, rc::Rc,
|
||||
};
|
||||
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use h2::server::{Connection, SendResponse};
|
||||
use h2::SendStream;
|
||||
use http::header::{HeaderValue, CONNECTION, CONTENT_LENGTH, DATE, TRANSFER_ENCODING};
|
||||
|
@ -19,6 +18,7 @@ use crate::http::payload::Payload;
|
|||
use crate::http::request::Request;
|
||||
use crate::http::response::Response;
|
||||
use crate::rt::time::{Instant, Sleep};
|
||||
use crate::util::{Bytes, BytesMut};
|
||||
use crate::Service;
|
||||
|
||||
const CHUNK_SIZE: usize = 16_384;
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures_core::Stream;
|
||||
use h2::RecvStream;
|
||||
|
||||
mod dispatcher;
|
||||
|
@ -11,7 +9,7 @@ mod service;
|
|||
|
||||
pub use self::dispatcher::Dispatcher;
|
||||
pub use self::service::H2Service;
|
||||
use crate::http::error::PayloadError;
|
||||
use crate::{http::error::PayloadError, util::Bytes, Stream};
|
||||
|
||||
/// H2 receive stream
|
||||
#[derive(Debug)]
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use std::task::{Context, Poll};
|
||||
use std::{future::Future, marker::PhantomData, net, pin::Pin, rc::Rc};
|
||||
|
||||
use bytes::Bytes;
|
||||
use h2::server::{self, Handshake};
|
||||
use log::error;
|
||||
|
||||
|
@ -13,6 +12,7 @@ use crate::http::helpers::DataFactory;
|
|||
use crate::http::request::Request;
|
||||
use crate::http::response::Response;
|
||||
use crate::rt::net::TcpStream;
|
||||
use crate::util::Bytes;
|
||||
use crate::{
|
||||
fn_factory, fn_service, pipeline_factory, IntoServiceFactory, Service,
|
||||
ServiceFactory,
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
use std::io;
|
||||
|
||||
use bytes::BytesMut;
|
||||
use percent_encoding::{AsciiSet, CONTROLS};
|
||||
|
||||
use crate::util::Extensions;
|
||||
use crate::util::{BytesMut, Extensions};
|
||||
|
||||
pub(crate) struct Writer<'a>(pub(crate) &'a mut BytesMut);
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
use std::{fmt, mem, pin::Pin, task::Context, task::Poll};
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures_core::Stream;
|
||||
use h2::RecvStream;
|
||||
|
||||
use super::error::PayloadError;
|
||||
use super::{h1, h2 as h2d};
|
||||
use super::{error::PayloadError, h1, h2 as h2d};
|
||||
use crate::{util::Bytes, Stream};
|
||||
|
||||
/// Type represent boxed payload
|
||||
pub type PayloadStream = Pin<Box<dyn Stream<Item = Result<Bytes, PayloadError>>>>;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
//! Http response
|
||||
use std::{cell::Ref, cell::RefMut, convert::TryFrom, error::Error, fmt, str};
|
||||
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use serde::Serialize;
|
||||
|
||||
#[cfg(feature = "cookie")]
|
||||
|
@ -12,7 +11,7 @@ use crate::http::error::{HttpError, ResponseError};
|
|||
use crate::http::header::{self, HeaderMap, HeaderName, HeaderValue};
|
||||
use crate::http::message::{ConnectionType, Message, ResponseHead};
|
||||
use crate::http::StatusCode;
|
||||
use crate::{util::Extensions, Stream};
|
||||
use crate::{util::Bytes, util::BytesMut, util::Extensions, Stream};
|
||||
|
||||
/// An HTTP Response
|
||||
pub struct Response<B = Body> {
|
||||
|
|
|
@ -3,13 +3,13 @@ use std::{
|
|||
task::Poll,
|
||||
};
|
||||
|
||||
use bytes::Bytes;
|
||||
use h2::server::{self, Handshake};
|
||||
|
||||
use crate::codec::{AsyncRead, AsyncWrite};
|
||||
use crate::framed::State;
|
||||
use crate::rt::net::TcpStream;
|
||||
use crate::service::{pipeline_factory, IntoServiceFactory, Service, ServiceFactory};
|
||||
use crate::util::Bytes;
|
||||
|
||||
use super::body::MessageBody;
|
||||
use super::builder::HttpServiceBuilder;
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
//! Test helpers to use during testing.
|
||||
use std::{convert::TryFrom, io, net, str::FromStr, sync::mpsc, thread, time};
|
||||
|
||||
use bytes::Bytes;
|
||||
|
||||
#[cfg(feature = "cookie")]
|
||||
use coo_kie::{Cookie, CookieJar};
|
||||
|
||||
use crate::codec::{AsyncRead, AsyncWrite, Framed};
|
||||
use crate::rt::{net::TcpStream, System};
|
||||
use crate::server::{Server, StreamServiceFactory};
|
||||
use crate::util::Bytes;
|
||||
|
||||
use super::client::error::WsClientError;
|
||||
use super::client::{Client, ClientRequest, ClientResponse, Connector};
|
||||
|
|
|
@ -3,11 +3,9 @@ use std::sync::{Arc, Mutex};
|
|||
use std::task::{Context, Poll, Waker};
|
||||
use std::{cmp, fmt, io, mem, pin::Pin, time};
|
||||
|
||||
use bytes::BytesMut;
|
||||
|
||||
use crate::codec::{AsyncRead, AsyncWrite, ReadBuf};
|
||||
use crate::rt::time::sleep;
|
||||
use crate::util::poll_fn;
|
||||
use crate::util::{poll_fn, BytesMut};
|
||||
|
||||
#[derive(Default)]
|
||||
struct AtomicWaker(Arc<Mutex<RefCell<Option<Waker>>>>);
|
||||
|
|
|
@ -161,15 +161,11 @@ where
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use bytes::BytesMut;
|
||||
use bytestring::ByteString;
|
||||
use std::{cell::Cell, rc::Rc, time::Duration};
|
||||
|
||||
use super::*;
|
||||
use crate::channel::mpsc;
|
||||
use crate::codec::Encoder;
|
||||
use crate::rt::time::sleep;
|
||||
use crate::{util::next, ws};
|
||||
use crate::util::{next, ByteString, BytesMut};
|
||||
use crate::{channel::mpsc, codec::Encoder, rt::time::sleep, ws};
|
||||
|
||||
#[crate::rt_test]
|
||||
async fn test_basic() {
|
||||
|
|
|
@ -625,8 +625,6 @@ where
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use bytes::Bytes;
|
||||
|
||||
use super::*;
|
||||
use crate::http::header::{self, HeaderValue};
|
||||
use crate::http::{Method, StatusCode};
|
||||
|
@ -634,7 +632,7 @@ mod tests {
|
|||
use crate::web::request::WebRequest;
|
||||
use crate::web::test::{call_service, init_service, read_body, TestRequest};
|
||||
use crate::web::{self, DefaultError, HttpRequest, HttpResponse};
|
||||
use crate::{fn_service, Service};
|
||||
use crate::{fn_service, util::Bytes, Service};
|
||||
|
||||
#[crate::rt_test]
|
||||
async fn test_default_resource() {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use std::net::SocketAddr;
|
||||
use std::rc::Rc;
|
||||
use std::{net::SocketAddr, rc::Rc};
|
||||
|
||||
use crate::router::ResourceDef;
|
||||
|
||||
|
@ -128,13 +127,11 @@ impl<Err: ErrorRenderer> ServiceConfig<Err> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use bytes::Bytes;
|
||||
|
||||
use super::*;
|
||||
use crate::http::{Method, StatusCode};
|
||||
use crate::web::test::{call_service, init_service, read_body, TestRequest};
|
||||
use crate::web::{self, App, HttpRequest, HttpResponse};
|
||||
use crate::Service;
|
||||
use crate::{util::Bytes, Service};
|
||||
|
||||
#[crate::rt_test]
|
||||
async fn test_configure_data() {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
//! Web error
|
||||
use std::{cell::RefCell, fmt, io::Write, marker::PhantomData};
|
||||
|
||||
use bytes::BytesMut;
|
||||
use derive_more::{Display, From};
|
||||
|
||||
pub use http::Error as HttpError;
|
||||
|
@ -13,7 +12,7 @@ use super::{HttpRequest, HttpResponse};
|
|||
use crate::http::body::Body;
|
||||
use crate::http::helpers::Writer;
|
||||
use crate::http::{error, header, StatusCode};
|
||||
use crate::util::Either;
|
||||
use crate::util::{BytesMut, Either};
|
||||
|
||||
pub use super::error_default::{DefaultError, Error};
|
||||
pub use crate::http::error::BlockingError;
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
//! Web error
|
||||
use std::io::Write;
|
||||
use std::str::Utf8Error;
|
||||
use std::{fmt, io};
|
||||
use std::{fmt, io, io::Write, str::Utf8Error};
|
||||
|
||||
use bytes::BytesMut;
|
||||
use serde::de::value::Error as DeError;
|
||||
use serde_json::error::Error as JsonError;
|
||||
use serde_urlencoded::ser::Error as FormError;
|
||||
|
@ -12,7 +9,7 @@ use crate::http::body::Body;
|
|||
use crate::http::helpers::Writer;
|
||||
use crate::http::ws::HandshakeError;
|
||||
use crate::http::{self, header, StatusCode};
|
||||
use crate::util::timeout::TimeoutError;
|
||||
use crate::util::{timeout::TimeoutError, BytesMut};
|
||||
|
||||
use super::error::{self, ErrorContainer, ErrorRenderer, WebResponseError};
|
||||
use super::{HttpRequest, HttpResponse};
|
||||
|
|
|
@ -252,9 +252,8 @@ tuple_from_req!(TupleFromRequest10, (0, A), (1, B), (2, C), (3, D), (4, E), (5,
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use bytes::Bytes;
|
||||
|
||||
use crate::http::header;
|
||||
use crate::util::Bytes;
|
||||
use crate::web::error::UrlencodedError;
|
||||
use crate::web::test::{from_request, TestRequest};
|
||||
use crate::web::types::{Form, FormConfig};
|
||||
|
|
|
@ -3,13 +3,12 @@ use std::fmt::{self, Display};
|
|||
use std::task::{Context, Poll};
|
||||
use std::{convert::TryFrom, env, error::Error, future::Future, pin::Pin, rc::Rc, time};
|
||||
|
||||
use bytes::Bytes;
|
||||
use regex::Regex;
|
||||
|
||||
use crate::http::body::{Body, BodySize, MessageBody, ResponseBody};
|
||||
use crate::http::header::HeaderName;
|
||||
use crate::service::{Service, Transform};
|
||||
use crate::util::{Either, HashSet, Ready};
|
||||
use crate::util::{Bytes, Either, HashSet, Ready};
|
||||
use crate::web::dev::{WebRequest, WebResponse};
|
||||
use crate::web::HttpResponse;
|
||||
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
use std::task::{Context, Poll};
|
||||
use std::{convert::TryFrom, future::Future, marker::PhantomData, pin::Pin};
|
||||
|
||||
use bytes::{Bytes, BytesMut};
|
||||
|
||||
use crate::http::error::HttpError;
|
||||
use crate::http::header::{HeaderMap, HeaderName, HeaderValue};
|
||||
use crate::http::{Response, ResponseBuilder, StatusCode};
|
||||
use crate::util::Either;
|
||||
use crate::util::{Bytes, BytesMut, Either};
|
||||
|
||||
use super::error::{
|
||||
DefaultError, ErrorContainer, ErrorRenderer, InternalError, WebResponseError,
|
||||
|
@ -418,15 +416,13 @@ where
|
|||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use bytes::{Bytes, BytesMut};
|
||||
|
||||
use super::*;
|
||||
use crate::http::body::{Body, ResponseBody};
|
||||
use crate::http::header::{HeaderValue, CONTENT_TYPE};
|
||||
use crate::http::{Response as HttpResponse, StatusCode};
|
||||
use crate::web;
|
||||
use crate::web::test::{init_service, TestRequest};
|
||||
use crate::Service;
|
||||
use crate::{util::Bytes, util::BytesMut, Service};
|
||||
|
||||
fn responder<T: Responder<DefaultError>>(
|
||||
responder: T,
|
||||
|
|
|
@ -276,10 +276,9 @@ array_routes!(12, a, b, c, d, e, f, g, h, i, j, k, l);
|
|||
mod tests {
|
||||
use std::time::Duration;
|
||||
|
||||
use bytes::Bytes;
|
||||
|
||||
use crate::http::{Method, StatusCode};
|
||||
use crate::rt::time::sleep;
|
||||
use crate::util::Bytes;
|
||||
use crate::web::test::{call_service, init_service, read_body, TestRequest};
|
||||
use crate::web::{self, error, App, DefaultError, HttpResponse};
|
||||
|
||||
|
|
|
@ -4,13 +4,10 @@ use std::{
|
|||
thread, time,
|
||||
};
|
||||
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use futures_core::Stream;
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::Serialize;
|
||||
|
||||
#[cfg(feature = "cookie")]
|
||||
use coo_kie::Cookie;
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::codec::{AsyncRead, AsyncWrite};
|
||||
use crate::http::body::MessageBody;
|
||||
|
@ -23,8 +20,10 @@ use crate::http::{HttpService, Method, Payload, Request, StatusCode, Uri, Versio
|
|||
use crate::router::{Path, ResourceDef};
|
||||
use crate::rt::{time::sleep, System};
|
||||
use crate::server::Server;
|
||||
use crate::util::{next, Extensions, Ready};
|
||||
use crate::{map_config, IntoService, IntoServiceFactory, Service, ServiceFactory};
|
||||
use crate::util::{next, Bytes, BytesMut, Extensions, Ready};
|
||||
use crate::{
|
||||
map_config, IntoService, IntoServiceFactory, Service, ServiceFactory, Stream,
|
||||
};
|
||||
|
||||
use crate::web::config::AppConfig;
|
||||
use crate::web::dev::{WebRequest, WebResponse};
|
||||
|
@ -130,8 +129,7 @@ where
|
|||
/// Helper function that returns a response body of a TestRequest
|
||||
///
|
||||
/// ```rust
|
||||
/// use bytes::Bytes;
|
||||
/// use ntex::http::header;
|
||||
/// use ntex::{http::header, util::Bytes};
|
||||
/// use ntex::web::{self, test, App, HttpResponse};
|
||||
///
|
||||
/// #[ntex::test]
|
||||
|
@ -173,8 +171,7 @@ where
|
|||
/// Helper function that returns a response body of a WebResponse.
|
||||
///
|
||||
/// ```rust
|
||||
/// use bytes::Bytes;
|
||||
/// use ntex::http::header;
|
||||
/// use ntex::{util::Bytes, http::header};
|
||||
/// use ntex::web::{self, test, App, HttpResponse};
|
||||
///
|
||||
/// #[ntex::test]
|
||||
|
|
|
@ -1,17 +1,14 @@
|
|||
//! Form extractor
|
||||
|
||||
use std::{fmt, future::Future, ops, pin::Pin, task::Context, task::Poll};
|
||||
|
||||
use bytes::BytesMut;
|
||||
use encoding_rs::{Encoding, UTF_8};
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::Serialize;
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
|
||||
#[cfg(feature = "compress")]
|
||||
use crate::http::encoding::Decoder;
|
||||
use crate::http::header::{CONTENT_LENGTH, CONTENT_TYPE};
|
||||
use crate::http::{HttpMessage, Payload, Response, StatusCode};
|
||||
use crate::util::next;
|
||||
use crate::util::{next, BytesMut};
|
||||
use crate::web::error::{ErrorRenderer, UrlencodedError, WebResponseError};
|
||||
use crate::web::responder::{Ready, Responder};
|
||||
use crate::web::{FromRequest, HttpRequest};
|
||||
|
@ -342,11 +339,11 @@ where
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use bytes::Bytes;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::*;
|
||||
use crate::http::header::{HeaderValue, CONTENT_TYPE};
|
||||
use crate::util::Bytes;
|
||||
use crate::web::test::{from_request, respond_to, TestRequest};
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug, PartialEq, derive_more::Display)]
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
//! Json extractor/responder
|
||||
|
||||
use std::{fmt, future::Future, ops, pin::Pin, sync::Arc, task::Context, task::Poll};
|
||||
|
||||
use bytes::BytesMut;
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::Serialize;
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
|
||||
#[cfg(feature = "compress")]
|
||||
use crate::http::encoding::Decoder;
|
||||
use crate::http::header::CONTENT_LENGTH;
|
||||
use crate::http::{HttpMessage, Payload, Response, StatusCode};
|
||||
use crate::util::next;
|
||||
use crate::util::{next, BytesMut};
|
||||
use crate::web::error::{ErrorRenderer, JsonError, JsonPayloadError, WebResponseError};
|
||||
use crate::web::responder::{Ready, Responder};
|
||||
use crate::web::{FromRequest, HttpRequest};
|
||||
|
@ -374,10 +371,9 @@ where
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use bytes::Bytes;
|
||||
|
||||
use super::*;
|
||||
use crate::http::header;
|
||||
use crate::util::Bytes;
|
||||
use crate::web::test::{from_request, respond_to, TestRequest};
|
||||
|
||||
#[derive(
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
//! Payload/Bytes/String extractors
|
||||
use std::{future::Future, pin::Pin, str, task::Context, task::Poll};
|
||||
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use encoding_rs::UTF_8;
|
||||
use futures_core::Stream;
|
||||
use mime::Mime;
|
||||
|
||||
use crate::http::{error, header, HttpMessage};
|
||||
use crate::util::{next, Either, Ready};
|
||||
use crate::util::{next, Bytes, BytesMut, Either, Ready};
|
||||
use crate::web::error::{ErrorRenderer, PayloadError};
|
||||
use crate::web::{FromRequest, HttpRequest};
|
||||
use crate::Stream;
|
||||
|
||||
/// Payload extractor returns request 's payload stream.
|
||||
///
|
||||
/// ## Example
|
||||
///
|
||||
/// ```rust
|
||||
/// use bytes::BytesMut;
|
||||
/// use futures::{Future, Stream};
|
||||
/// use ntex::util::BytesMut;
|
||||
/// use ntex::web::{self, error, App, HttpResponse};
|
||||
///
|
||||
/// /// extract binary data from request
|
||||
|
@ -66,8 +65,8 @@ impl Stream for Payload {
|
|||
/// ## Example
|
||||
///
|
||||
/// ```rust
|
||||
/// use bytes::BytesMut;
|
||||
/// use futures::{Future, Stream};
|
||||
/// use ntex::util::BytesMut;
|
||||
/// use ntex::web::{self, error, App, Error, HttpResponse};
|
||||
///
|
||||
/// /// extract binary data from request
|
||||
|
@ -112,8 +111,7 @@ impl<Err: ErrorRenderer> FromRequest<Err> for Payload {
|
|||
/// ## Example
|
||||
///
|
||||
/// ```rust
|
||||
/// use bytes::Bytes;
|
||||
/// use ntex::web;
|
||||
/// use ntex::{web, util::Bytes};
|
||||
///
|
||||
/// /// extract binary data from request
|
||||
/// async fn index(body: Bytes) -> String {
|
||||
|
@ -408,10 +406,9 @@ impl Future for HttpMessageBody {
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use bytes::Bytes;
|
||||
|
||||
use super::*;
|
||||
use crate::http::header;
|
||||
use crate::util::Bytes;
|
||||
use crate::web::test::{from_request, TestRequest};
|
||||
|
||||
#[crate::rt_test]
|
||||
|
|
|
@ -2,10 +2,6 @@ use std::{
|
|||
error::Error as StdError, marker::PhantomData, pin::Pin, task::Context, task::Poll,
|
||||
};
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures_core::Stream;
|
||||
use futures_sink::Sink;
|
||||
|
||||
pub use crate::ws::{CloseCode, CloseReason, Frame, Message};
|
||||
|
||||
use crate::http::body::{Body, BoxedBodyStream};
|
||||
|
@ -13,7 +9,7 @@ use crate::http::error::PayloadError;
|
|||
use crate::http::ws::{handshake, HandshakeError};
|
||||
use crate::service::{IntoServiceFactory, Service, ServiceFactory};
|
||||
use crate::web::{HttpRequest, HttpResponse};
|
||||
use crate::{channel::mpsc, rt, ws};
|
||||
use crate::{channel::mpsc, rt, util::Bytes, ws, Sink, Stream};
|
||||
|
||||
pub type WebSocketsSink =
|
||||
ws::StreamEncoder<mpsc::Sender<Result<Bytes, Box<dyn StdError>>>>;
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
use bytes::{Bytes, BytesMut};
|
||||
use bytestring::ByteString;
|
||||
use std::cell::Cell;
|
||||
|
||||
use crate::codec::{Decoder, Encoder};
|
||||
use crate::util::{ByteString, Bytes, BytesMut};
|
||||
|
||||
use super::frame::Parser;
|
||||
use super::proto::{CloseReason, OpCode};
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
use std::convert::TryFrom;
|
||||
|
||||
use bytes::{Buf, BufMut, BytesMut};
|
||||
use log::debug;
|
||||
use nanorand::{WyRand, RNG};
|
||||
|
||||
use super::mask::apply_mask;
|
||||
use super::proto::{CloseCode, CloseReason, OpCode};
|
||||
use super::ProtocolError;
|
||||
use super::{mask::apply_mask, ProtocolError};
|
||||
use crate::util::{Buf, BufMut, BytesMut};
|
||||
|
||||
/// WebSocket frame parser.
|
||||
#[derive(Debug)]
|
||||
|
@ -219,7 +218,7 @@ impl Parser {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use bytes::Bytes;
|
||||
use crate::util::Bytes;
|
||||
|
||||
struct F {
|
||||
finished: bool,
|
||||
|
|
|
@ -2,11 +2,9 @@ use std::{
|
|||
cell::RefCell, fmt, marker::PhantomData, pin::Pin, rc::Rc, task::Context, task::Poll,
|
||||
};
|
||||
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use ntex_codec::{Decoder, Encoder};
|
||||
|
||||
use super::{Codec, Frame, Message, ProtocolError};
|
||||
use crate::{Sink, Stream};
|
||||
use crate::util::{Bytes, BytesMut};
|
||||
use crate::{codec::Decoder, codec::Encoder, Sink, Stream};
|
||||
|
||||
/// Stream error
|
||||
#[derive(Debug, Display)]
|
||||
|
@ -170,10 +168,10 @@ where
|
|||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use bytestring::ByteString;
|
||||
|
||||
use super::*;
|
||||
use crate::{channel::mpsc, util::next, util::poll_fn, util::send};
|
||||
use crate::{
|
||||
channel::mpsc, util::next, util::poll_fn, util::send, util::ByteString,
|
||||
};
|
||||
|
||||
#[crate::rt_test]
|
||||
async fn test_decoder() {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use std::io;
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures::SinkExt;
|
||||
|
||||
use ntex::codec::{BytesCodec, Framed};
|
||||
|
@ -8,6 +7,7 @@ use ntex::connect::Connect;
|
|||
use ntex::rt::net::TcpStream;
|
||||
use ntex::server::test_server;
|
||||
use ntex::service::{fn_service, Service, ServiceFactory};
|
||||
use ntex::util::Bytes;
|
||||
|
||||
#[cfg(feature = "openssl")]
|
||||
#[ntex::test]
|
||||
|
|
|
@ -5,11 +5,9 @@ use std::sync::Arc;
|
|||
use std::time::Duration;
|
||||
|
||||
use brotli2::write::BrotliEncoder;
|
||||
use bytes::Bytes;
|
||||
use coo_kie::Cookie;
|
||||
use flate2::{read::GzDecoder, write::GzEncoder, write::ZlibEncoder, Compression};
|
||||
use futures::future::ok;
|
||||
use futures::stream::once;
|
||||
use futures::{future::ok, stream::once};
|
||||
use rand::Rng;
|
||||
|
||||
use ntex::http::client::error::{JsonPayloadError, SendRequestError};
|
||||
|
@ -17,6 +15,7 @@ use ntex::http::client::{Client, Connector};
|
|||
use ntex::http::test::server as test_server;
|
||||
use ntex::http::{header, HttpMessage, HttpService};
|
||||
use ntex::service::{map_config, pipeline_factory, Service};
|
||||
use ntex::util::Bytes;
|
||||
use ntex::web::dev::AppConfig;
|
||||
use ntex::web::middleware::Compress;
|
||||
use ntex::web::{self, test, App, BodyEncoding, Error, HttpRequest, HttpResponse};
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
use std::io;
|
||||
|
||||
use bytes::Bytes;
|
||||
use bytestring::ByteString;
|
||||
use futures::{future::ok, SinkExt, StreamExt};
|
||||
|
||||
use ntex::framed::{DispatchItem, Dispatcher, State};
|
||||
|
@ -9,7 +7,7 @@ use ntex::http::test::server as test_server;
|
|||
use ntex::http::ws::handshake_response;
|
||||
use ntex::http::{body::BodySize, h1, HttpService, Request, Response};
|
||||
use ntex::rt::net::TcpStream;
|
||||
use ntex::ws;
|
||||
use ntex::{util::ByteString, util::Bytes, ws};
|
||||
|
||||
async fn ws_service(
|
||||
msg: DispatchItem<ws::Codec>,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use std::io;
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures::future::{self, ok};
|
||||
|
||||
use ntex::http::test::server as test_server;
|
||||
use ntex::http::{HttpService, Method, Request, Response};
|
||||
use ntex::service::ServiceFactory;
|
||||
use ntex::util::Bytes;
|
||||
|
||||
const STR: &str = "Hello World Hello World Hello World Hello World Hello World \
|
||||
Hello World Hello World Hello World Hello World Hello World \
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#![cfg(feature = "openssl")]
|
||||
use std::io;
|
||||
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use futures::future::{err, ok, ready};
|
||||
use futures::stream::{once, Stream, StreamExt};
|
||||
use open_ssl::ssl::{AlpnError, SslAcceptor, SslFiletype, SslMethod};
|
||||
|
@ -11,6 +10,7 @@ use ntex::http::header::{self, HeaderName, HeaderValue};
|
|||
use ntex::http::test::server as test_server;
|
||||
use ntex::http::{body, HttpService, Method, Request, Response, StatusCode, Version};
|
||||
use ntex::service::{fn_service, ServiceFactory};
|
||||
use ntex::util::{Bytes, BytesMut};
|
||||
use ntex::web::error::InternalError;
|
||||
|
||||
async fn load_body<S>(stream: S) -> Result<BytesMut, PayloadError>
|
||||
|
|
|
@ -3,7 +3,6 @@ use std::fs::File;
|
|||
use std::io::{self, BufReader};
|
||||
use std::time::Duration;
|
||||
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use futures::future::{self, err, ok};
|
||||
use futures::stream::{once, Stream, StreamExt};
|
||||
use rust_tls::{
|
||||
|
@ -16,6 +15,7 @@ use ntex::http::header::{self, HeaderName, HeaderValue};
|
|||
use ntex::http::test::server as test_server;
|
||||
use ntex::http::{body, HttpService, Method, Request, Response, StatusCode, Version};
|
||||
use ntex::service::{fn_factory_with_config, fn_service};
|
||||
use ntex::util::{Bytes, BytesMut};
|
||||
use ntex::web::error::InternalError;
|
||||
|
||||
async fn load_body<S>(mut stream: S) -> Result<BytesMut, PayloadError>
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
use std::io::{Read, Write};
|
||||
use std::time::Duration;
|
||||
use std::{io, net, thread};
|
||||
use std::{io, net, thread, time::Duration};
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures::future::{self, ok, ready, FutureExt};
|
||||
use futures::stream::{once, StreamExt};
|
||||
use regex::Regex;
|
||||
|
@ -13,6 +11,7 @@ use ntex::http::{
|
|||
};
|
||||
use ntex::rt::time::sleep;
|
||||
use ntex::service::fn_service;
|
||||
use ntex::util::Bytes;
|
||||
use ntex::web::error;
|
||||
|
||||
#[ntex::test]
|
||||
|
|
|
@ -2,15 +2,13 @@ use std::sync::{Arc, Mutex};
|
|||
use std::task::{Context, Poll};
|
||||
use std::{cell::Cell, io, marker::PhantomData, pin::Pin};
|
||||
|
||||
use bytes::Bytes;
|
||||
use bytestring::ByteString;
|
||||
use futures::{future, Future, SinkExt, StreamExt};
|
||||
|
||||
use ntex::codec::{AsyncRead, AsyncWrite};
|
||||
use ntex::framed::{DispatchItem, Dispatcher, State, Timer};
|
||||
use ntex::http::{body, h1, test, ws::handshake, HttpService, Request, Response};
|
||||
use ntex::service::{fn_factory, Service};
|
||||
use ntex::ws;
|
||||
use ntex::{util::ByteString, util::Bytes, ws};
|
||||
|
||||
struct WsService<T>(Arc<Mutex<Cell<bool>>>, PhantomData<T>);
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ use std::sync::atomic::{AtomicUsize, Ordering::Relaxed};
|
|||
use std::sync::{mpsc, Arc};
|
||||
use std::{io, io::Read, net, thread, time};
|
||||
|
||||
use bytes::Bytes;
|
||||
use futures::future::{lazy, ok, FutureExt};
|
||||
use futures::SinkExt;
|
||||
|
||||
|
@ -10,6 +9,7 @@ use ntex::codec::{BytesCodec, Framed};
|
|||
use ntex::rt::net::TcpStream;
|
||||
use ntex::server::{Server, TestServer};
|
||||
use ntex::service::fn_service;
|
||||
use ntex::util::Bytes;
|
||||
|
||||
#[test]
|
||||
fn test_bind() {
|
||||
|
|
|
@ -4,7 +4,6 @@ use std::task::{Context, Poll};
|
|||
use std::time::Duration;
|
||||
|
||||
use brotli2::write::{BrotliDecoder, BrotliEncoder};
|
||||
use bytes::Bytes;
|
||||
use derive_more::Display;
|
||||
use flate2::read::GzDecoder;
|
||||
use flate2::write::{GzEncoder, ZlibDecoder, ZlibEncoder};
|
||||
|
@ -19,6 +18,7 @@ use ntex::http::header::{
|
|||
};
|
||||
use ntex::http::{Method, StatusCode};
|
||||
use ntex::rt::time::{sleep, Sleep};
|
||||
use ntex::util::Bytes;
|
||||
|
||||
use ntex::web::middleware::Compress;
|
||||
use ntex::web::{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue