mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-25 06:39:22 +02:00
@ -1,9 +1,8 @@
|
||||
use actix_service::ServiceFactory;
|
||||
use bytes::Bytes;
|
||||
use futures_util::future::{self, ok};
|
||||
|
||||
use actix_http::{http, HttpService, Request, Response};
|
||||
use actix_http_test::test_server;
|
||||
use actix_service::ServiceFactoryExt;
|
||||
use bytes::Bytes;
|
||||
use futures_util::future::{self, ok};
|
||||
|
||||
const STR: &str = "Hello World Hello World Hello World Hello World Hello World \
|
||||
Hello World Hello World Hello World Hello World Hello World \
|
||||
|
@ -1,19 +1,17 @@
|
||||
#![cfg(feature = "openssl")]
|
||||
use std::io;
|
||||
|
||||
use actix_http_test::test_server;
|
||||
use actix_service::{fn_service, ServiceFactory};
|
||||
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use futures_util::future::{err, ok, ready};
|
||||
use futures_util::stream::{once, Stream, StreamExt};
|
||||
use open_ssl::ssl::{AlpnError, SslAcceptor, SslFiletype, SslMethod};
|
||||
|
||||
use actix_http::error::{ErrorBadRequest, PayloadError};
|
||||
use actix_http::http::header::{self, HeaderName, HeaderValue};
|
||||
use actix_http::http::{Method, StatusCode, Version};
|
||||
use actix_http::httpmessage::HttpMessage;
|
||||
use actix_http::{body, Error, HttpService, Request, Response};
|
||||
use actix_http_test::test_server;
|
||||
use actix_service::{fn_service, ServiceFactoryExt};
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use futures_util::future::{err, ok, ready};
|
||||
use futures_util::stream::{once, Stream, StreamExt};
|
||||
use open_ssl::ssl::{AlpnError, SslAcceptor, SslFiletype, SslMethod};
|
||||
|
||||
async fn load_body<S>(stream: S) -> Result<BytesMut, PayloadError>
|
||||
where
|
||||
|
@ -3,7 +3,7 @@ use std::time::Duration;
|
||||
use std::{net, thread};
|
||||
|
||||
use actix_http_test::test_server;
|
||||
use actix_rt::time::delay_for;
|
||||
use actix_rt::time::sleep;
|
||||
use actix_service::fn_service;
|
||||
use bytes::Bytes;
|
||||
use futures_util::future::{self, err, ok, ready, FutureExt};
|
||||
@ -88,7 +88,7 @@ async fn test_expect_continue_h1() {
|
||||
let srv = test_server(|| {
|
||||
HttpService::build()
|
||||
.expect(fn_service(|req: Request| {
|
||||
delay_for(Duration::from_millis(20)).then(move |_| {
|
||||
sleep(Duration::from_millis(20)).then(move |_| {
|
||||
if req.head().uri.query() == Some("yes=") {
|
||||
ok(req)
|
||||
} else {
|
||||
|
@ -36,11 +36,10 @@ impl<T> Clone for WsService<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Service for WsService<T>
|
||||
impl<T> Service<(Request, Framed<T, h1::Codec>)> for WsService<T>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite + Unpin + 'static,
|
||||
{
|
||||
type Request = (Request, Framed<T, h1::Codec>);
|
||||
type Response = ();
|
||||
type Error = Error;
|
||||
type Future = Pin<Box<dyn Future<Output = Result<(), Error>>>>;
|
||||
@ -50,7 +49,10 @@ where
|
||||
Poll::Ready(Ok(()))
|
||||
}
|
||||
|
||||
fn call(&mut self, (req, mut framed): Self::Request) -> Self::Future {
|
||||
fn call(
|
||||
&mut self,
|
||||
(req, mut framed): (Request, Framed<T, h1::Codec>),
|
||||
) -> Self::Future {
|
||||
let fut = async move {
|
||||
let res = ws::handshake(req.head()).unwrap().message_body(());
|
||||
|
||||
|
Reference in New Issue
Block a user