mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-28 01:32:57 +01:00
remove unused code
This commit is contained in:
parent
c63838bb71
commit
f45038bbfe
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "actix-web"
|
||||
version = "0.7.10"
|
||||
version = "0.7.11"
|
||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||
description = "Actix web is a simple, pragmatic and extremely fast web framework for Rust."
|
||||
readme = "README.md"
|
||||
|
@ -8,7 +8,6 @@ Actix web is a simple, pragmatic and extremely fast web framework for Rust.
|
||||
* Client/server [WebSockets](https://actix.rs/docs/websockets/) support
|
||||
* Transparent content compression/decompression (br, gzip, deflate)
|
||||
* Configurable [request routing](https://actix.rs/docs/url-dispatch/)
|
||||
* Graceful server shutdown
|
||||
* Multipart streams
|
||||
* Static assets
|
||||
* SSL support with OpenSSL or `native-tls`
|
||||
@ -51,7 +50,7 @@ fn main() {
|
||||
* [Protobuf support](https://github.com/actix/examples/tree/master/protobuf/)
|
||||
* [Multipart streams](https://github.com/actix/examples/tree/master/multipart/)
|
||||
* [Simple websocket](https://github.com/actix/examples/tree/master/websocket/)
|
||||
* [Tera](https://github.com/actix/examples/tree/master/template_tera/) /
|
||||
* [Tera](https://github.com/actix/examples/tree/master/template_tera/) /
|
||||
[Askama](https://github.com/actix/examples/tree/master/template_askama/) templates
|
||||
* [Diesel integration](https://github.com/actix/examples/tree/master/diesel/)
|
||||
* [r2d2](https://github.com/actix/examples/tree/master/r2d2/)
|
||||
@ -66,8 +65,6 @@ You may consider checking out
|
||||
|
||||
* [TechEmpower Framework Benchmark](https://www.techempower.com/benchmarks/#section=data-r16&hw=ph&test=plaintext)
|
||||
|
||||
* Some basic benchmarks could be found in this [repository](https://github.com/fafhrd91/benchmarks).
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under either of
|
||||
|
@ -9,10 +9,7 @@ use tokio_reactor::Handle;
|
||||
use tokio_tcp::TcpStream;
|
||||
use tokio_timer::{sleep, Delay};
|
||||
|
||||
// use super::channel::HttpProtocol;
|
||||
use super::error::AcceptorError;
|
||||
use super::handler::HttpHandler;
|
||||
use super::settings::ServiceConfig;
|
||||
use super::IoStream;
|
||||
|
||||
/// This trait indicates types that can create acceptor service for http server.
|
||||
@ -275,56 +272,49 @@ impl<T: Service> Future for AcceptorTimeoutResponse<T> {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct ServerMessageAcceptor<T, H: HttpHandler> {
|
||||
pub(crate) struct ServerMessageAcceptor<T> {
|
||||
inner: T,
|
||||
settings: ServiceConfig<H>,
|
||||
}
|
||||
|
||||
impl<T, H> ServerMessageAcceptor<T, H>
|
||||
impl<T> ServerMessageAcceptor<T>
|
||||
where
|
||||
H: HttpHandler,
|
||||
T: NewService<Request = net::TcpStream>,
|
||||
{
|
||||
pub(crate) fn new(settings: ServiceConfig<H>, inner: T) -> Self {
|
||||
ServerMessageAcceptor { inner, settings }
|
||||
pub(crate) fn new(inner: T) -> Self {
|
||||
ServerMessageAcceptor { inner }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, H> NewService for ServerMessageAcceptor<T, H>
|
||||
impl<T> NewService for ServerMessageAcceptor<T>
|
||||
where
|
||||
H: HttpHandler,
|
||||
T: NewService<Request = net::TcpStream>,
|
||||
{
|
||||
type Request = ServerMessage;
|
||||
type Response = ();
|
||||
type Error = T::Error;
|
||||
type InitError = T::InitError;
|
||||
type Service = ServerMessageAcceptorService<T::Service, H>;
|
||||
type Future = ServerMessageAcceptorResponse<T, H>;
|
||||
type Service = ServerMessageAcceptorService<T::Service>;
|
||||
type Future = ServerMessageAcceptorResponse<T>;
|
||||
|
||||
fn new_service(&self) -> Self::Future {
|
||||
ServerMessageAcceptorResponse {
|
||||
fut: self.inner.new_service(),
|
||||
settings: self.settings.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct ServerMessageAcceptorResponse<T, H>
|
||||
pub(crate) struct ServerMessageAcceptorResponse<T>
|
||||
where
|
||||
H: HttpHandler,
|
||||
T: NewService<Request = net::TcpStream>,
|
||||
{
|
||||
fut: T::Future,
|
||||
settings: ServiceConfig<H>,
|
||||
}
|
||||
|
||||
impl<T, H> Future for ServerMessageAcceptorResponse<T, H>
|
||||
impl<T> Future for ServerMessageAcceptorResponse<T>
|
||||
where
|
||||
H: HttpHandler,
|
||||
T: NewService<Request = net::TcpStream>,
|
||||
{
|
||||
type Item = ServerMessageAcceptorService<T::Service, H>;
|
||||
type Item = ServerMessageAcceptorService<T::Service>;
|
||||
type Error = T::InitError;
|
||||
|
||||
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
||||
@ -332,20 +322,17 @@ where
|
||||
Async::NotReady => Ok(Async::NotReady),
|
||||
Async::Ready(service) => Ok(Async::Ready(ServerMessageAcceptorService {
|
||||
inner: service,
|
||||
settings: self.settings.clone(),
|
||||
})),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct ServerMessageAcceptorService<T, H: HttpHandler> {
|
||||
pub(crate) struct ServerMessageAcceptorService<T> {
|
||||
inner: T,
|
||||
settings: ServiceConfig<H>,
|
||||
}
|
||||
|
||||
impl<T, H> Service for ServerMessageAcceptorService<T, H>
|
||||
impl<T> Service for ServerMessageAcceptorService<T>
|
||||
where
|
||||
H: HttpHandler,
|
||||
T: Service<Request = net::TcpStream>,
|
||||
{
|
||||
type Request = ServerMessage;
|
||||
|
@ -60,7 +60,6 @@ where
|
||||
|
||||
if secure {
|
||||
Either::B(ServerMessageAcceptor::new(
|
||||
settings.clone(),
|
||||
TcpAcceptor::new(AcceptorTimeout::new(
|
||||
client_timeout,
|
||||
acceptor.create(),
|
||||
@ -74,7 +73,6 @@ where
|
||||
))
|
||||
} else {
|
||||
Either::A(ServerMessageAcceptor::new(
|
||||
settings.clone(),
|
||||
TcpAcceptor::new(acceptor.create().map_err(AcceptorError::Service))
|
||||
.map_err(|_| ())
|
||||
.map_init_err(|_| ())
|
||||
|
@ -50,7 +50,6 @@ where
|
||||
H: HttpHandler + 'static,
|
||||
{
|
||||
proto: HttpProtocol<T, H>,
|
||||
node: Option<Node<()>>,
|
||||
ka_timeout: Option<Delay>,
|
||||
}
|
||||
|
||||
@ -64,24 +63,11 @@ where
|
||||
|
||||
HttpChannel {
|
||||
ka_timeout,
|
||||
node: None,
|
||||
proto: HttpProtocol::Unknown(settings, io, BytesMut::with_capacity(8192)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, H> Drop for HttpChannel<T, H>
|
||||
where
|
||||
T: IoStream,
|
||||
H: HttpHandler + 'static,
|
||||
{
|
||||
fn drop(&mut self) {
|
||||
if let Some(mut node) = self.node.take() {
|
||||
node.remove()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, H> Future for HttpChannel<T, H>
|
||||
where
|
||||
T: IoStream,
|
||||
@ -114,22 +100,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
if self.node.is_none() {
|
||||
self.node = Some(Node::new(()));
|
||||
let _ = match self.proto {
|
||||
HttpProtocol::H1(ref mut h1) => {
|
||||
self.node.as_mut().map(|n| h1.settings().head().insert(n))
|
||||
}
|
||||
HttpProtocol::H2(ref mut h2) => {
|
||||
self.node.as_mut().map(|n| h2.settings().head().insert(n))
|
||||
}
|
||||
HttpProtocol::Unknown(ref mut settings, _, _) => {
|
||||
self.node.as_mut().map(|n| settings.head().insert(n))
|
||||
}
|
||||
HttpProtocol::None => unreachable!(),
|
||||
};
|
||||
}
|
||||
|
||||
let mut is_eof = false;
|
||||
let kind = match self.proto {
|
||||
HttpProtocol::H1(ref mut h1) => return h1.poll(),
|
||||
@ -206,7 +176,6 @@ where
|
||||
H: HttpHandler + 'static,
|
||||
{
|
||||
proto: HttpProtocol<T, H>,
|
||||
node: Option<Node<()>>,
|
||||
}
|
||||
|
||||
impl<T, H> H1Channel<T, H>
|
||||
@ -216,7 +185,6 @@ where
|
||||
{
|
||||
pub(crate) fn new(settings: ServiceConfig<H>, io: T) -> H1Channel<T, H> {
|
||||
H1Channel {
|
||||
node: None,
|
||||
proto: HttpProtocol::H1(h1::Http1Dispatcher::new(
|
||||
settings,
|
||||
io,
|
||||
@ -228,18 +196,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, H> Drop for H1Channel<T, H>
|
||||
where
|
||||
T: IoStream,
|
||||
H: HttpHandler + 'static,
|
||||
{
|
||||
fn drop(&mut self) {
|
||||
if let Some(mut node) = self.node.take() {
|
||||
node.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, H> Future for H1Channel<T, H>
|
||||
where
|
||||
T: IoStream,
|
||||
@ -249,16 +205,6 @@ where
|
||||
type Error = HttpDispatchError;
|
||||
|
||||
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
||||
if self.node.is_none() {
|
||||
self.node = Some(Node::new(()));
|
||||
match self.proto {
|
||||
HttpProtocol::H1(ref mut h1) => {
|
||||
self.node.as_mut().map(|n| h1.settings().head().insert(n));
|
||||
}
|
||||
_ => unreachable!(),
|
||||
};
|
||||
}
|
||||
|
||||
match self.proto {
|
||||
HttpProtocol::H1(ref mut h1) => h1.poll(),
|
||||
_ => unreachable!(),
|
||||
@ -266,88 +212,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) struct Node<T> {
|
||||
next: Option<*mut Node<T>>,
|
||||
prev: Option<*mut Node<T>>,
|
||||
element: T,
|
||||
}
|
||||
|
||||
impl<T> Node<T> {
|
||||
fn new(element: T) -> Self {
|
||||
Node {
|
||||
element,
|
||||
next: None,
|
||||
prev: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn insert<I>(&mut self, next_el: &mut Node<I>) {
|
||||
let next: *mut Node<T> = next_el as *const _ as *mut _;
|
||||
|
||||
if let Some(next2) = self.next {
|
||||
unsafe {
|
||||
let n = next2.as_mut().unwrap();
|
||||
n.prev = Some(next);
|
||||
}
|
||||
next_el.next = Some(next2 as *mut _);
|
||||
}
|
||||
self.next = Some(next);
|
||||
|
||||
unsafe {
|
||||
let next: &mut Node<T> = &mut *next;
|
||||
next.prev = Some(self as *mut _);
|
||||
}
|
||||
}
|
||||
|
||||
fn remove(&mut self) {
|
||||
let next = self.next.take();
|
||||
let prev = self.prev.take();
|
||||
|
||||
if let Some(prev) = prev {
|
||||
unsafe {
|
||||
prev.as_mut().unwrap().next = next;
|
||||
}
|
||||
}
|
||||
if let Some(next) = next {
|
||||
unsafe {
|
||||
next.as_mut().unwrap().prev = prev;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Node<()> {
|
||||
pub(crate) fn head() -> Self {
|
||||
Node {
|
||||
next: None,
|
||||
prev: None,
|
||||
element: (),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn traverse<T, H, F: Fn(&mut HttpProtocol<T, H>)>(&self, f: F)
|
||||
where
|
||||
T: IoStream,
|
||||
H: HttpHandler + 'static,
|
||||
{
|
||||
if let Some(n) = self.next.as_ref() {
|
||||
unsafe {
|
||||
let mut next: &mut Node<HttpProtocol<T, H>> =
|
||||
&mut *(n.as_ref().unwrap() as *const _ as *mut _);
|
||||
loop {
|
||||
f(&mut next.element);
|
||||
|
||||
next = if let Some(n) = next.next.as_ref() {
|
||||
&mut **n
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Wrapper for `AsyncRead + AsyncWrite` types
|
||||
pub(crate) struct WrapperStream<T>
|
||||
where
|
||||
|
@ -147,16 +147,6 @@ where
|
||||
disp
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn settings(&self) -> &ServiceConfig<H> {
|
||||
&self.settings
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn io(&mut self) -> &mut T {
|
||||
self.stream.get_mut()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn can_read(&self) -> bool {
|
||||
if self.flags.contains(Flags::READ_DISCONNECTED) {
|
||||
|
@ -89,15 +89,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn shutdown(&mut self) {
|
||||
self.state = State::Empty;
|
||||
self.tasks.clear();
|
||||
}
|
||||
|
||||
pub fn settings(&self) -> &ServiceConfig<H> {
|
||||
&self.settings
|
||||
}
|
||||
|
||||
pub fn poll(&mut self) -> Poll<(), HttpDispatchError> {
|
||||
self.poll_keepalive()?;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use std::cell::{Cell, RefCell, RefMut};
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::collections::VecDeque;
|
||||
use std::fmt::Write;
|
||||
use std::rc::Rc;
|
||||
@ -15,7 +15,6 @@ use time;
|
||||
use tokio_current_thread::spawn;
|
||||
use tokio_timer::{sleep, Delay};
|
||||
|
||||
use super::channel::Node;
|
||||
use super::message::{Request, RequestPool};
|
||||
use super::KeepAlive;
|
||||
use body::Body;
|
||||
@ -138,7 +137,6 @@ struct Inner<H> {
|
||||
ka_enabled: bool,
|
||||
bytes: Rc<SharedBytesPool>,
|
||||
messages: &'static RequestPool,
|
||||
node: RefCell<Node<()>>,
|
||||
date: Cell<Option<Date>>,
|
||||
}
|
||||
|
||||
@ -173,7 +171,6 @@ impl<H> ServiceConfig<H> {
|
||||
client_shutdown,
|
||||
bytes: Rc::new(SharedBytesPool::new()),
|
||||
messages: RequestPool::pool(settings),
|
||||
node: RefCell::new(Node::head()),
|
||||
date: Cell::new(None),
|
||||
}))
|
||||
}
|
||||
@ -183,10 +180,6 @@ impl<H> ServiceConfig<H> {
|
||||
ServiceConfigBuilder::new(handler)
|
||||
}
|
||||
|
||||
pub(crate) fn head(&self) -> RefMut<Node<()>> {
|
||||
self.0.node.borrow_mut()
|
||||
}
|
||||
|
||||
pub(crate) fn handler(&self) -> &H {
|
||||
&self.0.handler
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user