mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-28 01:52:57 +01:00
clippy warnings
This commit is contained in:
parent
644f1a9518
commit
72aa2d9eae
@ -46,7 +46,7 @@ impl Handler<ws::Message> for MyWebSocket {
|
||||
ws::Message::Ping(msg) => ctx.pong(&msg),
|
||||
ws::Message::Text(text) => ctx.text(text),
|
||||
ws::Message::Binary(bin) => ctx.binary(bin),
|
||||
ws::Message::Closed | ws::Message::Error => {
|
||||
ws::Message::Close(_) | ws::Message::Error => {
|
||||
ctx.stop();
|
||||
}
|
||||
_ => (),
|
||||
|
@ -161,10 +161,9 @@ impl Handler<ws::Message> for WsChatSession {
|
||||
},
|
||||
ws::Message::Binary(bin) =>
|
||||
println!("Unexpected binary"),
|
||||
ws::Message::Closed | ws::Message::Error => {
|
||||
ws::Message::Close(_) | ws::Message::Error => {
|
||||
ctx.stop();
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ impl Handler<ws::Message> for MyWebSocket {
|
||||
ws::Message::Ping(msg) => ctx.pong(&msg),
|
||||
ws::Message::Text(text) => ctx.text(text),
|
||||
ws::Message::Binary(bin) => ctx.binary(bin),
|
||||
ws::Message::Closed | ws::Message::Error => {
|
||||
ws::Message::Close(_) | ws::Message::Error => {
|
||||
ctx.stop();
|
||||
}
|
||||
_ => (),
|
||||
|
@ -149,7 +149,7 @@ impl<S> Application<S> where S: 'static {
|
||||
pub fn with_state(state: S) -> Application<S> {
|
||||
Application {
|
||||
parts: Some(ApplicationParts {
|
||||
state: state,
|
||||
state,
|
||||
prefix: "/".to_owned(),
|
||||
settings: ServerSettings::default(),
|
||||
default: Resource::default_not_found(),
|
||||
@ -361,17 +361,17 @@ impl<S> Application<S> where S: 'static {
|
||||
default: parts.default,
|
||||
encoding: parts.encoding,
|
||||
router: router.clone(),
|
||||
resources: resources,
|
||||
handlers: parts.handlers,
|
||||
resources,
|
||||
}
|
||||
));
|
||||
|
||||
HttpApplication {
|
||||
state: Rc::new(parts.state),
|
||||
prefix: prefix.to_owned(),
|
||||
inner: inner,
|
||||
router: router.clone(),
|
||||
middlewares: Rc::new(parts.middlewares),
|
||||
inner,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -176,12 +176,12 @@ impl HttpResponseParser {
|
||||
if let Some(decoder) = decoder {
|
||||
Ok(Async::Ready(
|
||||
(ClientResponse::new(
|
||||
ClientMessage{status: status, version: version,
|
||||
ClientMessage{status, version,
|
||||
headers: hdrs, cookies: None}), Some(decoder))))
|
||||
} else {
|
||||
Ok(Async::Ready(
|
||||
(ClientResponse::new(
|
||||
ClientMessage{status: status, version: version,
|
||||
ClientMessage{status, version,
|
||||
headers: hdrs, cookies: None}), None)))
|
||||
}
|
||||
}
|
||||
|
@ -63,16 +63,13 @@ impl SendRequest {
|
||||
pub(crate) fn with_connector(req: ClientRequest, conn: Addr<Unsync, ClientConnector>)
|
||||
-> SendRequest
|
||||
{
|
||||
SendRequest{
|
||||
req: req,
|
||||
state: State::New,
|
||||
conn: conn}
|
||||
SendRequest{req, conn, state: State::New}
|
||||
}
|
||||
|
||||
pub(crate) fn with_connection(req: ClientRequest, conn: Connection) -> SendRequest
|
||||
{
|
||||
SendRequest{
|
||||
req: req,
|
||||
req,
|
||||
state: State::Connection(conn),
|
||||
conn: ClientConnector::from_registry()}
|
||||
}
|
||||
@ -103,7 +100,7 @@ impl Future for SendRequest {
|
||||
Err(_) => return Err(SendRequestError::Connector(
|
||||
ClientConnectorError::Disconnected))
|
||||
},
|
||||
State::Connection(stream) => {
|
||||
State::Connection(conn) => {
|
||||
let mut writer = HttpClientWriter::new(SharedBytes::default());
|
||||
writer.start(&mut self.req)?;
|
||||
|
||||
@ -114,9 +111,7 @@ impl Future for SendRequest {
|
||||
};
|
||||
|
||||
let mut pl = Box::new(Pipeline {
|
||||
body: body,
|
||||
conn: stream,
|
||||
writer: writer,
|
||||
body, conn, writer,
|
||||
parser: Some(HttpResponseParser::default()),
|
||||
parser_buf: BytesMut::new(),
|
||||
disconnected: false,
|
||||
@ -221,11 +216,10 @@ impl Pipeline {
|
||||
let mut need_run = false;
|
||||
|
||||
// need write?
|
||||
match self.poll_write()
|
||||
if let Async::NotReady = self.poll_write()
|
||||
.map_err(|e| io::Error::new(io::ErrorKind::Other, format!("{}", e)))?
|
||||
{
|
||||
Async::NotReady => need_run = true,
|
||||
_ => (),
|
||||
need_run = true;
|
||||
}
|
||||
|
||||
// need read?
|
||||
|
@ -1,4 +1,6 @@
|
||||
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::io::{self, Write};
|
||||
use std::cell::RefCell;
|
||||
use std::fmt::Write as FmtWrite;
|
||||
@ -48,14 +50,14 @@ pub(crate) struct HttpClientWriter {
|
||||
|
||||
impl HttpClientWriter {
|
||||
|
||||
pub fn new(buf: SharedBytes) -> HttpClientWriter {
|
||||
let encoder = ContentEncoder::Identity(TransferEncoding::eof(buf.clone()));
|
||||
pub fn new(buffer: SharedBytes) -> HttpClientWriter {
|
||||
let encoder = ContentEncoder::Identity(TransferEncoding::eof(buffer.clone()));
|
||||
HttpClientWriter {
|
||||
flags: Flags::empty(),
|
||||
written: 0,
|
||||
headers_size: 0,
|
||||
buffer: buf,
|
||||
encoder: encoder,
|
||||
buffer,
|
||||
encoder,
|
||||
low: LOW_WATERMARK,
|
||||
high: HIGH_WATERMARK,
|
||||
}
|
||||
|
@ -230,10 +230,7 @@ pub struct Drain<A> {
|
||||
|
||||
impl<A> Drain<A> {
|
||||
pub fn new(fut: oneshot::Receiver<()>) -> Self {
|
||||
Drain {
|
||||
fut: fut,
|
||||
_a: PhantomData
|
||||
}
|
||||
Drain { fut, _a: PhantomData }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ impl<T: ResponseError> From<T> for Error {
|
||||
} else {
|
||||
None
|
||||
};
|
||||
Error { cause: Box::new(err), backtrace: backtrace }
|
||||
Error { cause: Box::new(err), backtrace }
|
||||
}
|
||||
}
|
||||
|
||||
@ -566,10 +566,10 @@ unsafe impl<T> Sync for InternalError<T> {}
|
||||
unsafe impl<T> Send for InternalError<T> {}
|
||||
|
||||
impl<T> InternalError<T> {
|
||||
pub fn new(err: T, status: StatusCode) -> Self {
|
||||
pub fn new(cause: T, status: StatusCode) -> Self {
|
||||
InternalError {
|
||||
cause: err,
|
||||
status: status,
|
||||
cause,
|
||||
status,
|
||||
backtrace: Backtrace::new(),
|
||||
}
|
||||
}
|
||||
|
@ -105,10 +105,7 @@ pub struct Directory{
|
||||
|
||||
impl Directory {
|
||||
pub fn new(base: PathBuf, path: PathBuf) -> Directory {
|
||||
Directory {
|
||||
base: base,
|
||||
path: path
|
||||
}
|
||||
Directory { base, path }
|
||||
}
|
||||
|
||||
fn can_list(&self, entry: &io::Result<DirEntry>) -> bool {
|
||||
|
@ -215,7 +215,7 @@ impl<S, H, R> WrapHandler<S, H, R>
|
||||
S: 'static,
|
||||
{
|
||||
pub fn new(h: H) -> Self {
|
||||
WrapHandler{h: h, s: PhantomData}
|
||||
WrapHandler{h, s: PhantomData}
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,7 +225,7 @@ impl<S, H, R> RouteHandler<S> for WrapHandler<S, H, R>
|
||||
S: 'static,
|
||||
{
|
||||
fn handle(&mut self, req: HttpRequest<S>) -> Reply {
|
||||
let req2 = req.clone_without_state();
|
||||
let req2 = req.without_state();
|
||||
match self.h.handle(req).respond_to(req2) {
|
||||
Ok(reply) => reply.into(),
|
||||
Err(err) => Reply::response(err.into()),
|
||||
@ -266,7 +266,7 @@ impl<S, H, F, R, E> RouteHandler<S> for AsyncHandler<S, H, F, R, E>
|
||||
S: 'static,
|
||||
{
|
||||
fn handle(&mut self, req: HttpRequest<S>) -> Reply {
|
||||
let req2 = req.clone_without_state();
|
||||
let req2 = req.without_state();
|
||||
let fut = (self.h)(req)
|
||||
.map_err(|e| e.into())
|
||||
.then(move |r| {
|
||||
@ -345,10 +345,10 @@ impl NormalizePath {
|
||||
/// Create new `NormalizePath` instance
|
||||
pub fn new(append: bool, merge: bool, redirect: StatusCode) -> NormalizePath {
|
||||
NormalizePath {
|
||||
append: append,
|
||||
merge: merge,
|
||||
append,
|
||||
merge,
|
||||
redirect,
|
||||
re_merge: Regex::new("//+").unwrap(),
|
||||
redirect: redirect,
|
||||
not_found: StatusCode::NOT_FOUND,
|
||||
}
|
||||
}
|
||||
|
@ -106,16 +106,16 @@ impl HttpRequest<()> {
|
||||
{
|
||||
HttpRequest(
|
||||
SharedHttpMessage::from_message(HttpMessage {
|
||||
method: method,
|
||||
uri: uri,
|
||||
version: version,
|
||||
headers: headers,
|
||||
method,
|
||||
uri,
|
||||
version,
|
||||
headers,
|
||||
payload,
|
||||
params: Params::new(),
|
||||
query: Params::new(),
|
||||
query_loaded: false,
|
||||
cookies: None,
|
||||
addr: None,
|
||||
payload: payload,
|
||||
extensions: Extensions::new(),
|
||||
info: None,
|
||||
}),
|
||||
@ -153,7 +153,7 @@ impl<S> HttpRequest<S> {
|
||||
|
||||
#[inline]
|
||||
/// Construct new http request without state.
|
||||
pub(crate) fn clone_without_state(&self) -> HttpRequest {
|
||||
pub(crate) fn without_state(&self) -> HttpRequest {
|
||||
HttpRequest(self.0.clone(), None, None)
|
||||
}
|
||||
|
||||
@ -483,7 +483,7 @@ impl<S> HttpRequest<S> {
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
pub fn body(self) -> RequestBody {
|
||||
RequestBody::from(self)
|
||||
RequestBody::new(self.without_state())
|
||||
}
|
||||
|
||||
/// Return stream to http payload processes as multipart.
|
||||
@ -553,7 +553,7 @@ impl<S> HttpRequest<S> {
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
pub fn urlencoded(self) -> UrlEncoded {
|
||||
UrlEncoded::from(self)
|
||||
UrlEncoded::new(self.without_state())
|
||||
}
|
||||
|
||||
/// Parse `application/json` encoded body.
|
||||
@ -677,9 +677,9 @@ pub struct UrlEncoded {
|
||||
}
|
||||
|
||||
impl UrlEncoded {
|
||||
pub fn from<S>(req: HttpRequest<S>) -> UrlEncoded {
|
||||
pub fn new(req: HttpRequest) -> UrlEncoded {
|
||||
UrlEncoded {
|
||||
req: Some(req.clone_without_state()),
|
||||
req: Some(req),
|
||||
limit: 262_144,
|
||||
fut: None,
|
||||
}
|
||||
@ -762,10 +762,10 @@ pub struct RequestBody {
|
||||
impl RequestBody {
|
||||
|
||||
/// Create `RequestBody` for request.
|
||||
pub fn from<S>(req: HttpRequest<S>) -> RequestBody {
|
||||
pub fn new(req: HttpRequest) -> RequestBody {
|
||||
RequestBody {
|
||||
limit: 262_144,
|
||||
req: Some(req.clone_without_state()),
|
||||
req: Some(req),
|
||||
fut: None,
|
||||
}
|
||||
}
|
||||
|
@ -659,11 +659,11 @@ impl InnerHttpResponse {
|
||||
#[inline]
|
||||
fn new(status: StatusCode, body: Body) -> InnerHttpResponse {
|
||||
InnerHttpResponse {
|
||||
status,
|
||||
body,
|
||||
version: None,
|
||||
headers: HeaderMap::with_capacity(16),
|
||||
status: status,
|
||||
reason: None,
|
||||
body: body,
|
||||
chunked: None,
|
||||
encoding: None,
|
||||
connection_type: None,
|
||||
|
@ -110,8 +110,8 @@ impl<'a> ConnectionInfo<'a> {
|
||||
ConnectionInfo {
|
||||
scheme: scheme.unwrap_or("http"),
|
||||
host: host.unwrap_or("localhost"),
|
||||
remote: remote,
|
||||
peer: peer,
|
||||
remote,
|
||||
peer,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
//! * Supported *HTTP/1.x* and *HTTP/2.0* protocols
|
||||
//! * Streaming and pipelining
|
||||
//! * Keep-alive and slow requests handling
|
||||
//! * *WebSockets* server/client
|
||||
//! * `WebSockets` server/client
|
||||
//! * Transparent content compression/decompression (br, gzip, deflate)
|
||||
//! * Configurable request routing
|
||||
//! * Multipart streams
|
||||
|
@ -95,7 +95,7 @@ impl DefaultHeadersBuilder {
|
||||
/// Finishes building and returns the built `DefaultHeaders` middleware.
|
||||
pub fn finish(&mut self) -> DefaultHeaders {
|
||||
let headers = self.headers.take().expect("cannot reuse middleware builder");
|
||||
DefaultHeaders{ ct: self.ct, headers: headers }
|
||||
DefaultHeaders{ ct: self.ct, headers }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -377,8 +377,8 @@ impl<S> SessionBackend<S> for CookieSessionBackend {
|
||||
FutOk(
|
||||
CookieSession {
|
||||
changed: false,
|
||||
state: state,
|
||||
inner: Rc::clone(&self.0),
|
||||
state,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -95,8 +95,8 @@ impl<S> Multipart<S> where S: Stream<Item=Bytes, Error=PayloadError> {
|
||||
safety: Safety::new(),
|
||||
inner: Some(Rc::new(RefCell::new(
|
||||
InnerMultipart {
|
||||
boundary,
|
||||
payload: PayloadRef::new(PayloadHelper::new(stream)),
|
||||
boundary: boundary,
|
||||
state: InnerState::FirstBoundary,
|
||||
item: InnerMultipartItem::None,
|
||||
})))
|
||||
@ -369,12 +369,7 @@ impl<S> Field<S> where S: Stream<Item=Bytes, Error=PayloadError> {
|
||||
|
||||
fn new(safety: Safety, headers: HeaderMap,
|
||||
ct: mime::Mime, inner: Rc<RefCell<InnerField<S>>>) -> Self {
|
||||
Field {
|
||||
ct: ct,
|
||||
headers: headers,
|
||||
inner: inner,
|
||||
safety: safety,
|
||||
}
|
||||
Field {ct, headers, inner, safety}
|
||||
}
|
||||
|
||||
pub fn headers(&self) -> &HeaderMap {
|
||||
@ -443,8 +438,8 @@ impl<S> InnerField<S> where S: Stream<Item=Bytes, Error=PayloadError> {
|
||||
};
|
||||
|
||||
Ok(InnerField {
|
||||
boundary,
|
||||
payload: Some(payload),
|
||||
boundary: boundary,
|
||||
eof: false,
|
||||
length: len })
|
||||
}
|
||||
@ -596,7 +591,7 @@ impl Safety {
|
||||
Safety {
|
||||
task: None,
|
||||
level: Rc::strong_count(&payload),
|
||||
payload: payload,
|
||||
payload,
|
||||
}
|
||||
}
|
||||
|
||||
@ -612,7 +607,7 @@ impl Clone for Safety {
|
||||
Safety {
|
||||
task: Some(current_task()),
|
||||
level: Rc::strong_count(&payload),
|
||||
payload: payload,
|
||||
payload,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -232,8 +232,8 @@ impl Inner {
|
||||
|
||||
fn new(eof: bool) -> Self {
|
||||
Inner {
|
||||
eof,
|
||||
len: 0,
|
||||
eof: eof,
|
||||
err: None,
|
||||
task: None,
|
||||
items: VecDeque::new(),
|
||||
|
@ -72,7 +72,7 @@ struct PipelineInfo<S> {
|
||||
impl<S> PipelineInfo<S> {
|
||||
fn new(req: HttpRequest<S>) -> PipelineInfo<S> {
|
||||
PipelineInfo {
|
||||
req: req,
|
||||
req,
|
||||
count: 0,
|
||||
mws: Rc::new(Vec::new()),
|
||||
error: None,
|
||||
@ -108,9 +108,8 @@ impl<S: 'static, H: PipelineHandler<S>> Pipeline<S, H> {
|
||||
handler: Rc<RefCell<H>>) -> Pipeline<S, H>
|
||||
{
|
||||
let mut info = PipelineInfo {
|
||||
req: req,
|
||||
req, mws,
|
||||
count: 0,
|
||||
mws: mws,
|
||||
error: None,
|
||||
context: None,
|
||||
disconnected: None,
|
||||
@ -307,7 +306,7 @@ impl<S: 'static, H> WaitingResponse<S, H> {
|
||||
RunMiddlewares::init(info, resp),
|
||||
ReplyItem::Future(fut) =>
|
||||
PipelineState::Handler(
|
||||
WaitingResponse { fut: fut, _s: PhantomData, _h: PhantomData }),
|
||||
WaitingResponse { fut, _s: PhantomData, _h: PhantomData }),
|
||||
}
|
||||
}
|
||||
|
||||
@ -355,7 +354,7 @@ impl<S: 'static, H> RunMiddlewares<S, H> {
|
||||
},
|
||||
Ok(Response::Future(fut)) => {
|
||||
return PipelineState::RunMiddlewares(
|
||||
RunMiddlewares { curr: curr, fut: Some(fut),
|
||||
RunMiddlewares { curr, fut: Some(fut),
|
||||
_s: PhantomData, _h: PhantomData })
|
||||
},
|
||||
};
|
||||
@ -444,7 +443,7 @@ impl<S: 'static, H> ProcessResponse<S, H> {
|
||||
#[inline]
|
||||
fn init(resp: HttpResponse) -> PipelineState<S, H> {
|
||||
PipelineState::Response(
|
||||
ProcessResponse{ resp: resp,
|
||||
ProcessResponse{ resp,
|
||||
iostate: IOState::Response,
|
||||
running: RunningState::Running,
|
||||
drain: None, _s: PhantomData, _h: PhantomData})
|
||||
@ -644,7 +643,7 @@ impl<S: 'static, H> FinishingMiddlewares<S, H> {
|
||||
if info.count == 0 {
|
||||
Completed::init(info)
|
||||
} else {
|
||||
let mut state = FinishingMiddlewares{resp: resp, fut: None,
|
||||
let mut state = FinishingMiddlewares{resp, fut: None,
|
||||
_s: PhantomData, _h: PhantomData};
|
||||
if let Some(st) = state.poll(info) {
|
||||
st
|
||||
|
12
src/route.rs
12
src/route.rs
@ -179,14 +179,10 @@ impl<S: 'static> Compose<S> {
|
||||
mws: Rc<Vec<Box<Middleware<S>>>>,
|
||||
handler: InnerHandler<S>) -> Self
|
||||
{
|
||||
let mut info = ComposeInfo {
|
||||
count: 0,
|
||||
req: req,
|
||||
mws: mws,
|
||||
handler: handler };
|
||||
let mut info = ComposeInfo { count: 0, req, mws, handler };
|
||||
let state = StartMiddlewares::init(&mut info);
|
||||
|
||||
Compose {state: state, info: info}
|
||||
Compose {state, info}
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,7 +304,7 @@ impl<S: 'static> WaitingResponse<S> {
|
||||
RunMiddlewares::init(info, resp),
|
||||
ReplyItem::Future(fut) =>
|
||||
ComposeState::Handler(
|
||||
WaitingResponse { fut: fut, _s: PhantomData }),
|
||||
WaitingResponse { fut, _s: PhantomData }),
|
||||
}
|
||||
}
|
||||
|
||||
@ -353,7 +349,7 @@ impl<S: 'static> RunMiddlewares<S> {
|
||||
},
|
||||
Ok(MiddlewareResponse::Future(fut)) => {
|
||||
return ComposeState::RunMiddlewares(
|
||||
RunMiddlewares { curr: curr, fut: Some(fut), _s: PhantomData })
|
||||
RunMiddlewares { curr, fut: Some(fut), _s: PhantomData })
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -46,13 +46,9 @@ impl Router {
|
||||
}
|
||||
}
|
||||
|
||||
let len = prefix.len();
|
||||
let prefix_len = prefix.len();
|
||||
(Router(Rc::new(
|
||||
Inner{ prefix: prefix,
|
||||
prefix_len: len,
|
||||
named: named,
|
||||
patterns: patterns,
|
||||
srv: settings })), resources)
|
||||
Inner{ prefix, prefix_len, named, patterns, srv: settings })), resources)
|
||||
}
|
||||
|
||||
/// Router prefix
|
||||
@ -168,10 +164,10 @@ impl Pattern {
|
||||
};
|
||||
|
||||
Pattern {
|
||||
tp: tp,
|
||||
tp,
|
||||
pattern,
|
||||
elements,
|
||||
name: name.into(),
|
||||
pattern: pattern,
|
||||
elements: elements,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,7 +237,7 @@ pub(crate) struct WrapperStream<T> where T: AsyncRead + AsyncWrite + 'static {
|
||||
|
||||
impl<T> WrapperStream<T> where T: AsyncRead + AsyncWrite + 'static {
|
||||
pub fn new(io: T) -> Self {
|
||||
WrapperStream{io: io}
|
||||
WrapperStream{ io }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -309,7 +309,7 @@ pub(crate) struct EncodedPayload {
|
||||
|
||||
impl EncodedPayload {
|
||||
pub fn new(inner: PayloadSender, enc: ContentEncoding) -> EncodedPayload {
|
||||
EncodedPayload{ inner: inner, error: false, payload: PayloadStream::new(enc) }
|
||||
EncodedPayload{ inner, error: false, payload: PayloadStream::new(enc) }
|
||||
}
|
||||
}
|
||||
|
||||
@ -821,10 +821,7 @@ impl AcceptEncoding {
|
||||
Err(_) => 0.0,
|
||||
}
|
||||
};
|
||||
Some(AcceptEncoding {
|
||||
encoding: encoding,
|
||||
quality: quality,
|
||||
})
|
||||
Some(AcceptEncoding{ encoding, quality })
|
||||
}
|
||||
|
||||
/// Parse a raw Accept-Encoding header value into an ordered list.
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]
|
||||
|
||||
use std::{self, io};
|
||||
use std::rc::Rc;
|
||||
use std::net::SocketAddr;
|
||||
@ -62,18 +64,20 @@ struct Entry {
|
||||
impl<T, H> Http1<T, H>
|
||||
where T: IoStream, H: HttpHandler + 'static
|
||||
{
|
||||
pub fn new(h: Rc<WorkerSettings<H>>, stream: T, addr: Option<SocketAddr>, buf: BytesMut)
|
||||
-> Self
|
||||
pub fn new(settings: Rc<WorkerSettings<H>>,
|
||||
stream: T,
|
||||
addr: Option<SocketAddr>, read_buf: BytesMut) -> Self
|
||||
{
|
||||
let bytes = h.get_shared_bytes();
|
||||
let bytes = settings.get_shared_bytes();
|
||||
Http1{ flags: Flags::KEEPALIVE,
|
||||
settings: h,
|
||||
addr: addr,
|
||||
stream: H1Writer::new(stream, bytes),
|
||||
reader: Reader::new(),
|
||||
read_buf: buf,
|
||||
tasks: VecDeque::new(),
|
||||
keepalive_timer: None }
|
||||
keepalive_timer: None,
|
||||
addr,
|
||||
read_buf,
|
||||
settings,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn settings(&self) -> &WorkerSettings<H> {
|
||||
@ -540,7 +544,7 @@ impl Reader {
|
||||
let (psender, payload) = Payload::new(false);
|
||||
let info = PayloadInfo {
|
||||
tx: PayloadType::new(&msg.get_mut().headers, psender),
|
||||
decoder: decoder,
|
||||
decoder,
|
||||
};
|
||||
msg.get_mut().payload = Some(payload);
|
||||
Ok(Async::Ready((HttpRequest::from_message(msg), Some(info))))
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]
|
||||
|
||||
use std::{io, mem};
|
||||
use bytes::BufMut;
|
||||
use futures::{Async, Poll};
|
||||
@ -39,11 +41,11 @@ impl<T: AsyncWrite> H1Writer<T> {
|
||||
pub fn new(stream: T, buf: SharedBytes) -> H1Writer<T> {
|
||||
H1Writer {
|
||||
flags: Flags::empty(),
|
||||
stream: stream,
|
||||
encoder: ContentEncoder::empty(buf.clone()),
|
||||
written: 0,
|
||||
headers_size: 0,
|
||||
buffer: buf,
|
||||
stream,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]
|
||||
|
||||
use std::{io, cmp, mem};
|
||||
use std::rc::Rc;
|
||||
use std::io::{Read, Write};
|
||||
@ -53,15 +55,17 @@ impl<T, H> Http2<T, H>
|
||||
where T: AsyncRead + AsyncWrite + 'static,
|
||||
H: HttpHandler + 'static
|
||||
{
|
||||
pub fn new(h: Rc<WorkerSettings<H>>, io: T, addr: Option<SocketAddr>, buf: Bytes) -> Self
|
||||
pub fn new(settings: Rc<WorkerSettings<H>>,
|
||||
io: T,
|
||||
addr: Option<SocketAddr>, buf: Bytes) -> Self
|
||||
{
|
||||
Http2{ flags: Flags::empty(),
|
||||
settings: h,
|
||||
addr: addr,
|
||||
tasks: VecDeque::new(),
|
||||
state: State::Handshake(
|
||||
server::handshake(IoWrapper{unread: Some(buf), inner: io})),
|
||||
keepalive_timer: None,
|
||||
addr,
|
||||
settings,
|
||||
}
|
||||
}
|
||||
|
||||
@ -286,10 +290,10 @@ impl Entry {
|
||||
|
||||
Entry {task: task.unwrap_or_else(|| Pipeline::error(HTTPNotFound)),
|
||||
payload: psender,
|
||||
recv: recv,
|
||||
stream: H2Writer::new(resp, settings.get_shared_bytes()),
|
||||
flags: EntryFlags::empty(),
|
||||
capacity: 0,
|
||||
recv,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]
|
||||
|
||||
use std::{io, cmp};
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use futures::{Async, Poll};
|
||||
@ -38,7 +40,7 @@ impl H2Writer {
|
||||
|
||||
pub fn new(respond: SendResponse<Bytes>, buf: SharedBytes) -> H2Writer {
|
||||
H2Writer {
|
||||
respond: respond,
|
||||
respond,
|
||||
stream: None,
|
||||
encoder: ContentEncoder::empty(buf.clone()),
|
||||
flags: Flags::empty(),
|
||||
|
@ -36,11 +36,7 @@ impl ServerSettings {
|
||||
} else {
|
||||
"localhost".to_owned()
|
||||
};
|
||||
ServerSettings {
|
||||
addr: addr,
|
||||
secure: secure,
|
||||
host: host,
|
||||
}
|
||||
ServerSettings { addr, secure, host }
|
||||
}
|
||||
|
||||
/// Returns the socket address of the local half of this TCP connection
|
||||
|
@ -62,7 +62,7 @@ impl<H: HttpHandler + 'static> Worker<H> {
|
||||
Worker {
|
||||
settings: Rc::new(WorkerSettings::new(h, keep_alive)),
|
||||
hnd: Arbiter::handle().clone(),
|
||||
handler: handler,
|
||||
handler,
|
||||
}
|
||||
}
|
||||
|
||||
|
18
src/test.rs
18
src/test.rs
@ -94,12 +94,12 @@ impl TestServer {
|
||||
let _ = sys.run();
|
||||
});
|
||||
|
||||
let (sys, addr) = rx.recv().unwrap();
|
||||
let (server_sys, addr) = rx.recv().unwrap();
|
||||
TestServer {
|
||||
addr: addr,
|
||||
addr,
|
||||
thread: Some(join),
|
||||
system: System::new("actix-test"),
|
||||
server_sys: sys,
|
||||
server_sys,
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,12 +131,12 @@ impl TestServer {
|
||||
let _ = sys.run();
|
||||
});
|
||||
|
||||
let (sys, addr) = rx.recv().unwrap();
|
||||
let (server_sys, addr) = rx.recv().unwrap();
|
||||
TestServer {
|
||||
addr: addr,
|
||||
addr,
|
||||
server_sys,
|
||||
thread: Some(join),
|
||||
system: System::new("actix-test"),
|
||||
server_sys: sys,
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,7 +346,7 @@ impl<S> TestRequest<S> {
|
||||
/// Start HttpRequest build process with application state
|
||||
pub fn with_state(state: S) -> TestRequest<S> {
|
||||
TestRequest {
|
||||
state: state,
|
||||
state,
|
||||
method: Method::GET,
|
||||
uri: Uri::from_str("/").unwrap(),
|
||||
version: Version::HTTP_11,
|
||||
@ -434,7 +434,7 @@ impl<S> TestRequest<S> {
|
||||
let req = self.finish();
|
||||
let resp = h.handle(req.clone());
|
||||
|
||||
match resp.respond_to(req.clone_without_state()) {
|
||||
match resp.respond_to(req.without_state()) {
|
||||
Ok(resp) => {
|
||||
match resp.into().into() {
|
||||
ReplyItem::Message(resp) => Ok(resp),
|
||||
@ -461,7 +461,7 @@ impl<S> TestRequest<S> {
|
||||
let mut core = Core::new().unwrap();
|
||||
match core.run(fut) {
|
||||
Ok(r) => {
|
||||
match r.respond_to(req.clone_without_state()) {
|
||||
match r.respond_to(req.without_state()) {
|
||||
Ok(reply) => match reply.into().into() {
|
||||
ReplyItem::Message(resp) => Ok(resp),
|
||||
_ => panic!("Nested async replies are not supported"),
|
||||
|
@ -130,7 +130,7 @@ impl WsClient {
|
||||
http_err: None,
|
||||
origin: None,
|
||||
protocols: None,
|
||||
conn: conn,
|
||||
conn,
|
||||
};
|
||||
cl.request.uri(uri.as_ref());
|
||||
cl
|
||||
@ -253,7 +253,7 @@ impl WsHandshake {
|
||||
io::ErrorKind::Other, "disconnected").into()))));
|
||||
|
||||
WsHandshake {
|
||||
key: key,
|
||||
key,
|
||||
inner: None,
|
||||
request: Some(request.with_connector(conn.clone())),
|
||||
tx: Some(tx),
|
||||
@ -261,7 +261,7 @@ impl WsHandshake {
|
||||
}
|
||||
} else {
|
||||
WsHandshake {
|
||||
key: key,
|
||||
key,
|
||||
inner: None,
|
||||
request: None,
|
||||
tx: None,
|
||||
@ -340,7 +340,7 @@ impl Future for WsHandshake {
|
||||
|
||||
let inner = Rc::new(UnsafeCell::new(inner));
|
||||
Ok(Async::Ready(
|
||||
(WsClientReader{inner: Rc::clone(&inner)}, WsClientWriter{inner: inner})))
|
||||
(WsClientReader{inner: Rc::clone(&inner)}, WsClientWriter{inner})))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,13 +146,7 @@ impl Frame {
|
||||
}
|
||||
|
||||
Ok(Async::Ready(Some(Frame {
|
||||
finished: finished,
|
||||
rsv1: rsv1,
|
||||
rsv2: rsv2,
|
||||
rsv3: rsv3,
|
||||
opcode: opcode,
|
||||
payload: data.into(),
|
||||
})))
|
||||
finished, rsv1, rsv2, rsv3, opcode, payload: data.into() })))
|
||||
}
|
||||
|
||||
/// Generate binary representation
|
||||
|
Loading…
Reference in New Issue
Block a user