mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
remove unused code
This commit is contained in:
parent
c63838bb71
commit
f45038bbfe
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "actix-web"
|
name = "actix-web"
|
||||||
version = "0.7.10"
|
version = "0.7.11"
|
||||||
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
|
||||||
description = "Actix web is a simple, pragmatic and extremely fast web framework for Rust."
|
description = "Actix web is a simple, pragmatic and extremely fast web framework for Rust."
|
||||||
readme = "README.md"
|
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
|
* Client/server [WebSockets](https://actix.rs/docs/websockets/) support
|
||||||
* Transparent content compression/decompression (br, gzip, deflate)
|
* Transparent content compression/decompression (br, gzip, deflate)
|
||||||
* Configurable [request routing](https://actix.rs/docs/url-dispatch/)
|
* Configurable [request routing](https://actix.rs/docs/url-dispatch/)
|
||||||
* Graceful server shutdown
|
|
||||||
* Multipart streams
|
* Multipart streams
|
||||||
* Static assets
|
* Static assets
|
||||||
* SSL support with OpenSSL or `native-tls`
|
* SSL support with OpenSSL or `native-tls`
|
||||||
@ -66,8 +65,6 @@ You may consider checking out
|
|||||||
|
|
||||||
* [TechEmpower Framework Benchmark](https://www.techempower.com/benchmarks/#section=data-r16&hw=ph&test=plaintext)
|
* [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
|
## License
|
||||||
|
|
||||||
This project is licensed under either of
|
This project is licensed under either of
|
||||||
|
@ -9,10 +9,7 @@ use tokio_reactor::Handle;
|
|||||||
use tokio_tcp::TcpStream;
|
use tokio_tcp::TcpStream;
|
||||||
use tokio_timer::{sleep, Delay};
|
use tokio_timer::{sleep, Delay};
|
||||||
|
|
||||||
// use super::channel::HttpProtocol;
|
|
||||||
use super::error::AcceptorError;
|
use super::error::AcceptorError;
|
||||||
use super::handler::HttpHandler;
|
|
||||||
use super::settings::ServiceConfig;
|
|
||||||
use super::IoStream;
|
use super::IoStream;
|
||||||
|
|
||||||
/// This trait indicates types that can create acceptor service for http server.
|
/// 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,
|
inner: T,
|
||||||
settings: ServiceConfig<H>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, H> ServerMessageAcceptor<T, H>
|
impl<T> ServerMessageAcceptor<T>
|
||||||
where
|
where
|
||||||
H: HttpHandler,
|
|
||||||
T: NewService<Request = net::TcpStream>,
|
T: NewService<Request = net::TcpStream>,
|
||||||
{
|
{
|
||||||
pub(crate) fn new(settings: ServiceConfig<H>, inner: T) -> Self {
|
pub(crate) fn new(inner: T) -> Self {
|
||||||
ServerMessageAcceptor { inner, settings }
|
ServerMessageAcceptor { inner }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, H> NewService for ServerMessageAcceptor<T, H>
|
impl<T> NewService for ServerMessageAcceptor<T>
|
||||||
where
|
where
|
||||||
H: HttpHandler,
|
|
||||||
T: NewService<Request = net::TcpStream>,
|
T: NewService<Request = net::TcpStream>,
|
||||||
{
|
{
|
||||||
type Request = ServerMessage;
|
type Request = ServerMessage;
|
||||||
type Response = ();
|
type Response = ();
|
||||||
type Error = T::Error;
|
type Error = T::Error;
|
||||||
type InitError = T::InitError;
|
type InitError = T::InitError;
|
||||||
type Service = ServerMessageAcceptorService<T::Service, H>;
|
type Service = ServerMessageAcceptorService<T::Service>;
|
||||||
type Future = ServerMessageAcceptorResponse<T, H>;
|
type Future = ServerMessageAcceptorResponse<T>;
|
||||||
|
|
||||||
fn new_service(&self) -> Self::Future {
|
fn new_service(&self) -> Self::Future {
|
||||||
ServerMessageAcceptorResponse {
|
ServerMessageAcceptorResponse {
|
||||||
fut: self.inner.new_service(),
|
fut: self.inner.new_service(),
|
||||||
settings: self.settings.clone(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct ServerMessageAcceptorResponse<T, H>
|
pub(crate) struct ServerMessageAcceptorResponse<T>
|
||||||
where
|
where
|
||||||
H: HttpHandler,
|
|
||||||
T: NewService<Request = net::TcpStream>,
|
T: NewService<Request = net::TcpStream>,
|
||||||
{
|
{
|
||||||
fut: T::Future,
|
fut: T::Future,
|
||||||
settings: ServiceConfig<H>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, H> Future for ServerMessageAcceptorResponse<T, H>
|
impl<T> Future for ServerMessageAcceptorResponse<T>
|
||||||
where
|
where
|
||||||
H: HttpHandler,
|
|
||||||
T: NewService<Request = net::TcpStream>,
|
T: NewService<Request = net::TcpStream>,
|
||||||
{
|
{
|
||||||
type Item = ServerMessageAcceptorService<T::Service, H>;
|
type Item = ServerMessageAcceptorService<T::Service>;
|
||||||
type Error = T::InitError;
|
type Error = T::InitError;
|
||||||
|
|
||||||
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
||||||
@ -332,20 +322,17 @@ where
|
|||||||
Async::NotReady => Ok(Async::NotReady),
|
Async::NotReady => Ok(Async::NotReady),
|
||||||
Async::Ready(service) => Ok(Async::Ready(ServerMessageAcceptorService {
|
Async::Ready(service) => Ok(Async::Ready(ServerMessageAcceptorService {
|
||||||
inner: service,
|
inner: service,
|
||||||
settings: self.settings.clone(),
|
|
||||||
})),
|
})),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct ServerMessageAcceptorService<T, H: HttpHandler> {
|
pub(crate) struct ServerMessageAcceptorService<T> {
|
||||||
inner: T,
|
inner: T,
|
||||||
settings: ServiceConfig<H>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, H> Service for ServerMessageAcceptorService<T, H>
|
impl<T> Service for ServerMessageAcceptorService<T>
|
||||||
where
|
where
|
||||||
H: HttpHandler,
|
|
||||||
T: Service<Request = net::TcpStream>,
|
T: Service<Request = net::TcpStream>,
|
||||||
{
|
{
|
||||||
type Request = ServerMessage;
|
type Request = ServerMessage;
|
||||||
|
@ -60,7 +60,6 @@ where
|
|||||||
|
|
||||||
if secure {
|
if secure {
|
||||||
Either::B(ServerMessageAcceptor::new(
|
Either::B(ServerMessageAcceptor::new(
|
||||||
settings.clone(),
|
|
||||||
TcpAcceptor::new(AcceptorTimeout::new(
|
TcpAcceptor::new(AcceptorTimeout::new(
|
||||||
client_timeout,
|
client_timeout,
|
||||||
acceptor.create(),
|
acceptor.create(),
|
||||||
@ -74,7 +73,6 @@ where
|
|||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
Either::A(ServerMessageAcceptor::new(
|
Either::A(ServerMessageAcceptor::new(
|
||||||
settings.clone(),
|
|
||||||
TcpAcceptor::new(acceptor.create().map_err(AcceptorError::Service))
|
TcpAcceptor::new(acceptor.create().map_err(AcceptorError::Service))
|
||||||
.map_err(|_| ())
|
.map_err(|_| ())
|
||||||
.map_init_err(|_| ())
|
.map_init_err(|_| ())
|
||||||
|
@ -50,7 +50,6 @@ where
|
|||||||
H: HttpHandler + 'static,
|
H: HttpHandler + 'static,
|
||||||
{
|
{
|
||||||
proto: HttpProtocol<T, H>,
|
proto: HttpProtocol<T, H>,
|
||||||
node: Option<Node<()>>,
|
|
||||||
ka_timeout: Option<Delay>,
|
ka_timeout: Option<Delay>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,24 +63,11 @@ where
|
|||||||
|
|
||||||
HttpChannel {
|
HttpChannel {
|
||||||
ka_timeout,
|
ka_timeout,
|
||||||
node: None,
|
|
||||||
proto: HttpProtocol::Unknown(settings, io, BytesMut::with_capacity(8192)),
|
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>
|
impl<T, H> Future for HttpChannel<T, H>
|
||||||
where
|
where
|
||||||
T: IoStream,
|
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 mut is_eof = false;
|
||||||
let kind = match self.proto {
|
let kind = match self.proto {
|
||||||
HttpProtocol::H1(ref mut h1) => return h1.poll(),
|
HttpProtocol::H1(ref mut h1) => return h1.poll(),
|
||||||
@ -206,7 +176,6 @@ where
|
|||||||
H: HttpHandler + 'static,
|
H: HttpHandler + 'static,
|
||||||
{
|
{
|
||||||
proto: HttpProtocol<T, H>,
|
proto: HttpProtocol<T, H>,
|
||||||
node: Option<Node<()>>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, H> H1Channel<T, H>
|
impl<T, H> H1Channel<T, H>
|
||||||
@ -216,7 +185,6 @@ where
|
|||||||
{
|
{
|
||||||
pub(crate) fn new(settings: ServiceConfig<H>, io: T) -> H1Channel<T, H> {
|
pub(crate) fn new(settings: ServiceConfig<H>, io: T) -> H1Channel<T, H> {
|
||||||
H1Channel {
|
H1Channel {
|
||||||
node: None,
|
|
||||||
proto: HttpProtocol::H1(h1::Http1Dispatcher::new(
|
proto: HttpProtocol::H1(h1::Http1Dispatcher::new(
|
||||||
settings,
|
settings,
|
||||||
io,
|
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>
|
impl<T, H> Future for H1Channel<T, H>
|
||||||
where
|
where
|
||||||
T: IoStream,
|
T: IoStream,
|
||||||
@ -249,16 +205,6 @@ where
|
|||||||
type Error = HttpDispatchError;
|
type Error = HttpDispatchError;
|
||||||
|
|
||||||
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
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 {
|
match self.proto {
|
||||||
HttpProtocol::H1(ref mut h1) => h1.poll(),
|
HttpProtocol::H1(ref mut h1) => h1.poll(),
|
||||||
_ => unreachable!(),
|
_ => 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
|
/// Wrapper for `AsyncRead + AsyncWrite` types
|
||||||
pub(crate) struct WrapperStream<T>
|
pub(crate) struct WrapperStream<T>
|
||||||
where
|
where
|
||||||
|
@ -147,16 +147,6 @@ where
|
|||||||
disp
|
disp
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub fn settings(&self) -> &ServiceConfig<H> {
|
|
||||||
&self.settings
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
pub(crate) fn io(&mut self) -> &mut T {
|
|
||||||
self.stream.get_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn can_read(&self) -> bool {
|
fn can_read(&self) -> bool {
|
||||||
if self.flags.contains(Flags::READ_DISCONNECTED) {
|
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> {
|
pub fn poll(&mut self) -> Poll<(), HttpDispatchError> {
|
||||||
self.poll_keepalive()?;
|
self.poll_keepalive()?;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use std::cell::{Cell, RefCell, RefMut};
|
use std::cell::{Cell, RefCell};
|
||||||
use std::collections::VecDeque;
|
use std::collections::VecDeque;
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
@ -15,7 +15,6 @@ use time;
|
|||||||
use tokio_current_thread::spawn;
|
use tokio_current_thread::spawn;
|
||||||
use tokio_timer::{sleep, Delay};
|
use tokio_timer::{sleep, Delay};
|
||||||
|
|
||||||
use super::channel::Node;
|
|
||||||
use super::message::{Request, RequestPool};
|
use super::message::{Request, RequestPool};
|
||||||
use super::KeepAlive;
|
use super::KeepAlive;
|
||||||
use body::Body;
|
use body::Body;
|
||||||
@ -138,7 +137,6 @@ struct Inner<H> {
|
|||||||
ka_enabled: bool,
|
ka_enabled: bool,
|
||||||
bytes: Rc<SharedBytesPool>,
|
bytes: Rc<SharedBytesPool>,
|
||||||
messages: &'static RequestPool,
|
messages: &'static RequestPool,
|
||||||
node: RefCell<Node<()>>,
|
|
||||||
date: Cell<Option<Date>>,
|
date: Cell<Option<Date>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +171,6 @@ impl<H> ServiceConfig<H> {
|
|||||||
client_shutdown,
|
client_shutdown,
|
||||||
bytes: Rc::new(SharedBytesPool::new()),
|
bytes: Rc::new(SharedBytesPool::new()),
|
||||||
messages: RequestPool::pool(settings),
|
messages: RequestPool::pool(settings),
|
||||||
node: RefCell::new(Node::head()),
|
|
||||||
date: Cell::new(None),
|
date: Cell::new(None),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@ -183,10 +180,6 @@ impl<H> ServiceConfig<H> {
|
|||||||
ServiceConfigBuilder::new(handler)
|
ServiceConfigBuilder::new(handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn head(&self) -> RefMut<Node<()>> {
|
|
||||||
self.0.node.borrow_mut()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn handler(&self) -> &H {
|
pub(crate) fn handler(&self) -> &H {
|
||||||
&self.0.handler
|
&self.0.handler
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user