id stringlengths 20 30 | source stringclasses 1
value | chunk_index int64 0 520k | token_count int32 154 512 | content stringlengths 185 57.5k |
|---|---|---|---|---|
rust_dataset_chunk_1300 | rust_dataset.txt | 1,300 | 512 | if there is idle connection for given key.
let mut map = inner.available.borrow_mut();
if let Some(conns) = map.get_mut(&key) {
let now = Instant::now();
while let Some(mut c) = conns.pop_front() {
let config = &inner.con... |
rust_dataset_chunk_1301 | rust_dataset.txt | 1,301 | 512 | /// IO is pending and a new request would wake it.
Live,
/// IO unexpectedly has unread data and should be dropped.
Tainted,
/// IO should be skipped but not dropped.
Skip,
}
impl<Io> Future for ConnectionCheckFuture<'_, Io>
where
Io: AsyncRead + Unpin,
{
type Output = ConnectionState;
... |
rust_dataset_chunk_1302 | rust_dataset.txt | 1,302 | 512 | Client object.
permit: OwnedSemaphorePermit,
}
impl<Io: ConnectionIo> Acquired<Io> {
/// Close the IO.
pub(super) fn close(&self, conn: ConnectionInnerType<Io>) {
self.inner.close(conn);
}
/// Release IO back into pool.
pub(super) fn release(&self, conn: ConnectionInnerType<Io>, creat... |
rust_dataset_chunk_1303 | rust_dataset.txt | 1,303 | 512 | ::Response, Self::Error>>;
actix_service::always_ready!();
fn call(&self, _: Connect) -> Self::Future {
self.generated.set(self.generated.get() + 1);
let generated = self.generated.clone();
Box::pin(async { Ok((TestStream(generated), Protocol::Http1)) })
}
... |
rust_dataset_chunk_1304 | rust_dataset.txt | 1,304 | 512 | release(conn);
let conn = pool.call(req.clone()).await.unwrap();
assert_eq!(1, generated_clone.get());
release(conn);
actix_rt::time::sleep(Duration::from_millis(1500)).await;
actix_rt::task::yield_now().await;
let conn = pool.call(req).await.unwrap();
// Note... |
rust_dataset_chunk_1305 | rust_dataset.txt | 1,305 | 512 | {
uri: Uri::from_static("https://crates.io"),
addr: None,
};
let conn = pool.call(req.clone()).await.unwrap();
assert_eq!(1, generated_clone.get());
release(conn);
let conn = pool.call(req).await.unwrap();
assert_eq!(1, generated_clone.get());
... |
rust_dataset_chunk_1306 | rust_dataset.txt | 1,306 | 512 | actix_codec::Framed;
use actix_http::{h1::ClientCodec, Payload, RequestHead, RequestHeadType, ResponseHead};
use actix_service::Service;
use futures_core::{future::LocalBoxFuture, ready};
use pin_project_lite::pin_project;
use crate::{
any_body::AnyBody,
client::{Connect as ClientConnect, ConnectError, Connec... |
rust_dataset_chunk_1307 | rust_dataset.txt | 1,307 | 512 | struct DefaultConnector<S> {
connector: S,
}
impl<S> DefaultConnector<S> {
pub(crate) fn new(connector: S) -> Self {
Self { connector }
}
}
impl<S, Io> Service<ConnectRequest> for DefaultConnector<S>
where
S: Service<ClientConnect, Error = ConnectError, Response = Connection<Io>>,
Io: Con... |
rust_dataset_chunk_1308 | rust_dataset.txt | 1,308 | 512 | ConnectRequestFuture::Client {
fut: connection.send_request(head, body),
};
self.set(fut);
}
ConnectRequest::Tunnel(head, ..) => {
// send request
let fu... |
rust_dataset_chunk_1309 | rust_dataset.txt | 1,309 | 512 | error
#[display("{}", _0)]
Protocol(WsProtocolError),
/// Send request error
#[display("{}", _0)]
SendRequest(SendRequestError),
}
impl std::error::Error for WsClientError {}
impl From<InvalidUrl> for WsClientError {
fn from(err: InvalidUrl) -> Self {
WsClientError::SendRequest(err.i... |
rust_dataset_chunk_1310 | rust_dataset.txt | 1,310 | 512 | }
/// Send a body.
pub fn send_body<B>(&self, body: B) -> SendClientRequest
where
B: MessageBody + 'static,
{
RequestSender::Rc(Rc::clone(&self.head), None).send_body(
self.addr,
self.response_decompress,
self.timeout,
&self.config,
... |
rust_dataset_chunk_1311 | rust_dataset.txt | 1,311 | 512 | extra headers.
pub struct FrozenSendBuilder {
req: FrozenClientRequest,
extra_headers: HeaderMap,
err: Option<HttpError>,
}
impl FrozenSendBuilder {
pub(crate) fn new(req: FrozenClientRequest, extra_headers: HeaderMap) -> Self {
Self {
req,
extra_headers,
er... |
rust_dataset_chunk_1312 | rust_dataset.txt | 1,312 | 512 | self.err {
return err.into();
}
RequestSender::Rc(self.req.head, Some(self.extra_headers)).send_stream(
self.req.addr,
self.req.response_decompress,
self.req.timeout,
&self.req.config,
stream,
)
}
/// Complete req... |
rust_dataset_chunk_1313 | rust_dataset.txt | 1,313 | 512 | //! ## URL-encoded Form
//! ```no_run
//! # #[actix_rt::main]
//! # async fn main() -> Result<(), awc::error::SendRequestError> {
//! let params = [("foo", "bar"), ("baz", "quux")];
//!
//! let mut client = awc::Client::default();
//! let response = client.post("http://httpbin.org/post")
//! .send_form(¶ms)
//!... |
rust_dataset_chunk_1314 | rust_dataset.txt | 1,314 | 512 | .rs/favicon.ico")]
#![cfg_attr(docsrs, feature(doc_cfg))]
pub use actix_http::body;
#[cfg(feature = "cookies")]
pub use cookie;
mod any_body;
mod builder;
mod client;
mod connect;
pub mod error;
mod frozen;
pub mod middleware;
mod request;
mod responses;
mod sender;
pub mod test;
pub mod ws;
pub mod http {
//! V... |
rust_dataset_chunk_1315 | rust_dataset.txt | 1,315 | 512 | T1, parent: T2) -> Self {
NestTransform {
child,
parent,
_service: PhantomData,
}
}
}
impl<T1, T2, S, Req> Transform<S, Req> for NestTransform<T1, T2, S, Req>
where
T1: Transform<S, Req>,
T2: Transform<T1::Transform, Req>,
{
type Transform = T2::Tran... |
rust_dataset_chunk_1316 | rust_dataset.txt | 1,316 | 512 | RedirectService<S> {
max_redirect_times: u8,
connector: Rc<S>,
}
impl<S> Service<ConnectRequest> for RedirectService<S>
where
S: Service<ConnectRequest, Response = ConnectResponse, Error = SendRequestError> + 'static,
{
type Response = S::Response;
type Error = S::Error;
type Future = Redirect... |
rust_dataset_chunk_1317 | rust_dataset.txt | 1,317 | 512 | }
}
}
impl<S> Future for RedirectServiceFuture<S>
where
S: Service<ConnectRequest, Response = ConnectResponse, Error = SendRequestError> + 'static,
{
type Output = Result<ConnectResponse, SendRequestError>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
match ... |
rust_dataset_chunk_1318 | rust_dataset.txt | 1,318 | 512 | .
let mut head = RequestHead::default();
head.uri = next_uri.clone();
head.method = method.clone();
head.headers = headers.clone();
let head = RequestHeadType::Owned(head);
l... |
rust_dataset_chunk_1319 | rust_dataset.txt | 1,319 | 512 | .map_err(|err| SendRequestError::Url(InvalidUrl::HttpError(err)))?
} else {
uri
};
Ok(uri)
}
fn remove_sensitive_headers(headers: &mut header::HeaderMap, prev_uri: &Uri, next_uri: &Uri) {
if next_uri.host() != prev_uri.host()
|| next_uri.port() != prev_uri.port()
|| next_uri.s... |
rust_dataset_chunk_1320 | rust_dataset.txt | 1,320 | 512 | async fn redirect_without_location() {
let client = ClientBuilder::new()
.disable_redirects()
.wrap(Redirect::new().max_redirect_times(10))
.finish();
let srv = actix_test::start(|| {
App::new().service(web::resource("/").route(web::to(|| async {
... |
rust_dataset_chunk_1321 | rust_dataset.txt | 1,321 | 512 | resource("/").route(web::to(root)))
.service(web::resource("/test").route(web::to(test)))
});
let res = srv.post("/").send_body("Hello").await.unwrap();
assert_eq!(res.status().as_u16(), 200);
}
#[tokio::test(flavor = "local")]
async fn test_redirect_status_kind_301... |
rust_dataset_chunk_1322 | rust_dataset.txt | 1,322 | 512 | value"))
.disable_redirects()
.finish();
let res = client.get(srv.url("/")).send().await.unwrap();
assert_eq!(res.status().as_u16(), 302);
let client = ClientBuilder::new()
.add_default_header(("custom", "value"))
.finish();
let res = clie... |
rust_dataset_chunk_1323 | rust_dataset.txt | 1,323 | 512 | ::resource("/").route(web::to(root)))
.service(web::resource("/test1").route(web::to(test1)))
.service(web::resource("/test2").route(web::to(test2)))
});
// send a request to different origins, http://srv1/ then http://srv2/. So it should remove the header
let cl... |
rust_dataset_chunk_1324 | rust_dataset.txt | 1,324 | 512 | HeaderValue::from_str("value").unwrap(),
);
headers.insert(header::COOKIE, HeaderValue::from_str("value").unwrap());
headers
}
// Same origin
let prev_uri = Uri::from_str("https://host/path1").unwrap();
let next_uri = Uri::from_str("ht... |
rust_dataset_chunk_1325 | rust_dataset.txt | 1,325 | 512 | ;
use serde::Serialize;
#[cfg(feature = "cookies")]
use crate::cookie::{Cookie, CookieJar};
use crate::{
client::ClientConfig,
error::{FreezeRequestError, InvalidUrl},
frozen::FrozenClientRequest,
sender::{PrepForSendingError, RequestSender, SendClientRequest},
BoxError,
};
/// An HTTP Client requ... |
rust_dataset_chunk_1326 | rust_dataset.txt | 1,326 | 512 | /// Get HTTP URI of request.
pub fn get_uri(&self) -> &Uri {
&self.head.uri
}
/// Set socket address of the server.
///
/// This address is used for connection. If address is not
/// provided url's host name get resolved.
pub fn address(mut self, addr: net::SocketAddr) -> Self {
... |
rust_dataset_chunk_1327 | rust_dataset.txt | 1,327 | 512 | (err) => self.err = Some(err.into()),
};
self
}
/// Append a header, keeping any that were set with an equivalent field name.
///
/// ```no_run
/// use awc::{http::header, Client};
///
/// Client::new()
/// .get("http://www.rust-lang.org")
/// .insert_header... |
rust_dataset_chunk_1328 | rust_dataset.txt | 1,328 | 512 | )),
))
}
/// Set HTTP bearer authentication header
pub fn bearer_auth(self, token: impl fmt::Display) -> Self {
self.insert_header((header::AUTHORIZATION, format!("Bearer {}", token)))
}
/// Set a cookie
///
/// ```no_run
/// use awc::{cookie::Cookie, Client};
///
... |
rust_dataset_chunk_1329 | rust_dataset.txt | 1,329 | 512 | ()?;
let request = FrozenClientRequest {
head: Rc::new(slf.head),
addr: slf.addr,
response_decompress: slf.response_decompress,
timeout: slf.timeout,
config: slf.config,
};
Ok(request)
}
/// Complete request construction and ... |
rust_dataset_chunk_1330 | rust_dataset.txt | 1,330 | 512 | RequestSender::Owned(slf.head).send_stream(
slf.addr,
slf.response_decompress,
slf.timeout,
&slf.config,
stream,
)
}
/// Set an empty body and generate `ClientRequest`.
pub fn send(self) -> SendClientRequest {
let slf = match self... |
rust_dataset_chunk_1331 | rust_dataset.txt | 1,331 | 512 | (clippy::vec_init_then_push)]
#[cfg(feature = "__compress")]
let accept_encoding = {
let mut encoding = vec![];
#[cfg(feature = "compress-brotli")]
{
encoding.push("br");
}
#[cfg(feature = "comp... |
rust_dataset_chunk_1332 | rust_dataset.txt | 1,332 | 512 | server") {
req.append_header((header::USER_AGENT, val))
} else {
req
};
let req = if let Some(_val) = Option::<&str>::None {
req.append_header((header::ALLOW, "1"))
} else {
req
};
let mut req = req.content_length(100);
... |
rust_dataset_chunk_1333 | rust_dataset.txt | 1,333 | 512 | headers
.get(header::AUTHORIZATION)
.unwrap()
.to_str()
.unwrap(),
"Basic dXNlcm5hbWU6"
);
}
#[tokio::test(flavor = "local")]
async fn client_bearer_auth() {
let req = Client::new().get("/").bearer_auth("someS3cr3tA... |
rust_dataset_chunk_1334 | rust_dataset.txt | 1,334 | 512 | /// Creates a JSON body stream reader from a response by taking its payload.
pub fn new(res: &mut ClientResponse<S>) -> Self {
// check content-type
let json = if let Ok(Some(mime)) = res.mime_type() {
mime.subtype() == mime::JSON || mime.suffix() == Some(mime::JSON)
} else {... |
rust_dataset_chunk_1335 | rust_dataset.txt | 1,335 | 512 | #[cfg(test)]
mod tests {
use actix_http::BoxedPayloadStream;
use serde::{Deserialize, Serialize};
use static_assertions::assert_impl_all;
use super::*;
use crate::test::TestResponse;
assert_impl_all!(JsonBody<BoxedPayloadStream, String>: Unpin);
#[derive(Serialize, Deserialize, PartialEq,... |
rust_dataset_chunk_1336 | rust_dataset.txt | 1,336 | 512 | req).await;
assert_eq!(
json.ok().unwrap(),
MyObject {
name: "test".to_owned()
}
);
}
}
--- FILE: actix-web/awc/src/responses/mod.rs ---
use std::{future::Future, io, pin::Pin, task::Context};
use actix_http::error::PayloadError;
use actix_rt::... |
rust_dataset_chunk_1337 | rust_dataset.txt | 1,337 | 512 | limit,
}
}
}
impl<S> Future for ReadBody<S>
where
S: Stream<Item = Result<Bytes, PayloadError>>,
{
type Output = Result<Bytes, PayloadError>;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let mut this = self.project();
while let Some(chunk) = rea... |
rust_dataset_chunk_1338 | rust_dataset.txt | 1,338 | 512 | {
let length = match res.headers().get(&header::CONTENT_LENGTH) {
Some(value) => {
let len = value.to_str().ok().and_then(|s| s.parse::<usize>().ok());
match len {
None => return Self::err(PayloadError::UnknownLength),
len => ... |
rust_dataset_chunk_1339 | rust_dataset.txt | 1,339 | 512 | ::CONTENT_LENGTH, "10000000")).finish();
match req.body().await.err().unwrap() {
PayloadError::Overflow => {}
_ => unreachable!("error"),
}
let mut req = TestResponse::default()
.set_payload(Bytes::from_static(b"test"))
.finish();
assert_e... |
rust_dataset_chunk_1340 | rust_dataset.txt | 1,340 | 512 | ]
pub fn status(&self) -> StatusCode {
self.head().status
}
#[inline]
/// Returns request's headers.
pub fn headers(&self) -> &HeaderMap {
&self.head().headers
}
/// Map the current body type to another using a closure. Returns a new response.
///
/// Closure receiv... |
rust_dataset_chunk_1341 | rust_dataset.txt | 1,341 | 512 | Vec::new();
for hdr in self.headers().get_all(&actix_http::header::SET_COOKIE) {
let s = std::str::from_utf8(hdr.as_bytes()).map_err(CookieParseError::from)?;
cookies.push(Cookie::parse_encoded(s)?.into_owned());
}
self.extensions_mut().insert(Cookies... |
rust_dataset_chunk_1342 | rust_dataset.txt | 1,342 | 512 | # use awc::Client;
/// # #[actix_rt::main]
/// # async fn async_ctx() -> Result<(), Box<dyn std::error::Error>> {
/// let client = Client::default();
/// let mut res = client.get("https://httpbin.org/json").send().await?;
/// let val = res.json::<serde_json::Value>().await?;
/// assert!(val.is_... |
rust_dataset_chunk_1343 | rust_dataset.txt | 1,343 | 512 | --- FILE: actix-web/awc/src/sender.rs ---
use std::{
future::Future,
net,
pin::Pin,
rc::Rc,
task::{Context, Poll},
time::Duration,
};
use actix_http::{
body::{BodyStream, MessageBody},
error::HttpError,
header::{self, HeaderMap, HeaderName, TryIntoHeaderValue},
RequestHead, Requ... |
rust_dataset_chunk_1344 | rust_dataset.txt | 1,344 | 512 | /// Future that sends request's payload and resolves to a server response.
#[must_use = "futures do nothing unless polled"]
pub enum SendClientRequest {
Fut(
Pin<Box<dyn Future<Output = Result<ConnectResponse, SendRequestError>>>>,
// FIXME: use a pinned Sleep instead of box.
Option<Pin<Box<... |
rust_dataset_chunk_1345 | rust_dataset.txt | 1,345 | 512 | self.get_mut();
match this {
SendClientRequest::Fut(send, delay, _) => {
if let Some(delay) = delay {
if delay.as_mut().poll(cx).is_ready() {
return Poll::Ready(Err(SendRequestError::Timeout));
}
}
... |
rust_dataset_chunk_1346 | rust_dataset.txt | 1,346 | 512 | Serialize,
) -> SendClientRequest {
let body = match serde_json::to_string(&value) {
Ok(body) => body,
Err(err) => return PrepForSendingError::Json(err).into(),
};
if let Err(err) = self.set_header_if_none(header::CONTENT_TYPE, "application/json") {
retu... |
rust_dataset_chunk_1347 | rust_dataset.txt | 1,347 | 512 | Ok(value) => {
head.headers.insert(key, value);
}
Err(err) => return Err(err.into()),
}
}
}
RequestSender::Rc(head, extra_headers) => {
if !head.headers.contains_key(&... |
rust_dataset_chunk_1348 | rust_dataset.txt | 1,348 | 512 | self;
}
panic!("Can not create header");
}
/// Set cookie for this response
#[cfg(feature = "cookies")]
pub fn cookie(mut self, cookie: Cookie<'_>) -> Self {
self.cookies.add(cookie.into_owned());
self
}
/// Set response's payload
pub fn set_payload<B: Into... |
rust_dataset_chunk_1349 | rust_dataset.txt | 1,349 | 512 | = Client::new()
//! .ws("ws://echo.websocket.org")
//! .connect()
//! .await
//! .unwrap();
//!
//! connection
//! .send(ws::Message::Text("Echo".into()))
//! .await
//! .unwrap();
//! let response = connection.next().await.unwrap().unwrap();
//!
//! ... |
rust_dataset_chunk_1350 | rust_dataset.txt | 1,350 | 512 | err,
config,
addr: None,
origin: None,
protocols: None,
max_size: 65_536,
server_mode: false,
#[cfg(feature = "cookies")]
cookies: None,
}
}
/// Set socket address of the server.
///
/// This addres... |
rust_dataset_chunk_1351 | rust_dataset.txt | 1,351 | 512 | <HeaderName as TryFrom<K>>::Error: Into<HttpError>,
V: TryIntoHeaderValue,
{
match HeaderName::try_from(key) {
Ok(key) => match value.try_into_value() {
Ok(value) => {
self.head.headers.append(key, value);
}
Err(err) =>... |
rust_dataset_chunk_1352 | rust_dataset.txt | 1,352 | 512 | >(self, token: T) -> Self
where
T: fmt::Display,
{
self.header(AUTHORIZATION, format!("Bearer {}", token))
}
/// Returns whether headers should be sent in Camel-Case.
///
/// Default is `false`.
#[inline]
pub fn camel_case_headers(&self) -> bool {
self.head.camel... |
rust_dataset_chunk_1353 | rust_dataset.txt | 1,353 | 512 | (origin) = self.origin.take() {
self.head.headers.insert(header::ORIGIN, origin);
}
self.head.set_connection_type(ConnectionType::Upgrade);
#[allow(clippy::declare_interior_mutable_const)]
const HV_WEBSOCKET: HeaderValue = HeaderValue::from_static("websocket");
self... |
rust_dataset_chunk_1354 | rust_dataset.txt | 1,354 | 512 |
};
if !has_hdr {
log::trace!("Invalid upgrade header");
return Err(WsClientError::InvalidUpgradeHeader);
}
// Check for "CONNECTION" header
let mut upgrade = false;
for conn in head.headers.get_all(header::CONNECTION) {
if let Ok(valu... |
rust_dataset_chunk_1355 | rust_dataset.txt | 1,355 | 512 | !(f, " {:?}: {:?}", key, val)?;
}
Ok(())
}
}
/// Formatter for host (hostname+port) header values.
struct Host<'a> {
hostname: &'a str,
port: Option<http::uri::Port<&'a str>>,
}
impl fmt::Display for Host<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.wri... |
rust_dataset_chunk_1356 | rust_dataset.txt | 1,356 | 512 | = Client::new().ws("/").bearer_auth("someS3cr3tAutht0k3n");
assert_eq!(
req.head
.headers
.get(header::AUTHORIZATION)
.unwrap()
.to_str()
.unwrap(),
"Bearer someS3cr3tAutht0k3n"
);
#[allow(c... |
rust_dataset_chunk_1357 | rust_dataset.txt | 1,357 | 512 | map_config, ServiceFactoryExt as _};
use actix_web::{dev::AppConfig, http::header, web, App, Error, HttpRequest, HttpResponse};
use awc::error::{JsonPayloadError, PayloadError, SendRequestError};
use base64::prelude::*;
use bytes::Bytes;
use cookie::Cookie;
use futures_util::stream;
use rand::distr::{Alphanumeric, Sam... |
rust_dataset_chunk_1358 | rust_dataset.txt | 1,358 | 512 | let srv = actix_test::start(|| {
App::new()
.service(web::resource("/").route(web::to(|_: web::Json<String>| HttpResponse::Ok())))
});
let request = srv
.get("/")
.insert_header(("x-test", "111"))
.send_json(&"TEST".to_string());
let response = request.await.unw... |
rust_dataset_chunk_1359 | rust_dataset.txt | 1,359 | 512 | finish();
let request = client
.get(srv.url("/"))
.timeout(Duration::from_millis(50))
.send();
match request.await {
Err(SendRequestError::Timeout) => {}
_ => panic!(),
}
}
#[tokio::test(flavor = "local")]
async fn response_timeout() {
use futures_util::{stream::... |
rust_dataset_chunk_1360 | rust_dataset.txt | 1,360 | 512 | ayloadError::Io(e))) => {
assert_eq!(e.kind(), std::io::ErrorKind::TimedOut)
}
_ => panic!("Response error type is not matched"),
}
}
#[tokio::test(flavor = "local")]
async fn connection_reuse() {
let num = Arc::new(AtomicUsize::new(0));
let num2 = num.clone();
let srv = te... |
rust_dataset_chunk_1361 | rust_dataset.txt | 1,361 | 512 | assert!(response.status().is_success());
// two connection
assert_eq!(num.load(Ordering::Relaxed), 2);
}
#[tokio::test(flavor = "local")]
async fn connection_server_close() {
let num = Arc::new(AtomicUsize::new(0));
let num2 = num.clone();
let srv = test_server(move || {
let num2 = num2.... |
rust_dataset_chunk_1362 | rust_dataset.txt | 1,362 | 512 | let req2 = client.post(srv.url("/"));
let req2_fut = req2.send();
// read response 1
let bytes = response.body().await.unwrap();
assert_eq!(bytes, Bytes::from_static(STR.as_ref()));
// req 2
let response = req2_fut.await.unwrap();
assert!(response.status().is_success());
// two co... |
rust_dataset_chunk_1363 | rust_dataset.txt | 1,363 | 512 | let res = awc::Client::new()
.get(srv.url("/?qp=5"))
.send()
.await
.unwrap();
assert!(res.status().is_success());
}
#[cfg(feature = "compress-gzip")]
#[tokio::test(flavor = "local")]
async fn no_decompress() {
let srv = actix_test::start(|| {
App::new()
... |
rust_dataset_chunk_1364 | rust_dataset.txt | 1,364 | 512 | Ok()
.insert_header(header::ContentEncoding::Gzip)
.body(utils::gzip::encode(STR.repeat(10)))
})))
});
// client request
let mut response = srv.post("/").send().await.unwrap();
assert!(response.status().is_success());
// read response
let bytes = respons... |
rust_dataset_chunk_1365 | rust_dataset.txt | 1,365 | 512 | Encoding::Brotli)
.body(utils::brotli::encode(data))
})))
});
// client request
let mut response = srv.post("/").send_body(data.clone()).await.unwrap();
assert!(response.status().is_success());
// read response
let bytes = response.body().await.unwrap();
assert_eq!(... |
rust_dataset_chunk_1366 | rust_dataset.txt | 1,366 | 512 | _eq!(bytes, Bytes::from_static(STR.as_ref()));
}
#[tokio::test(flavor = "local")]
async fn body_streaming_implicit() {
let srv = actix_test::start(|| {
App::new().default_service(web::to(|| async {
let body =
stream::once(async { Ok::<_, Infallible>(Bytes::from_static(STR.as_byt... |
rust_dataset_chunk_1367 | rust_dataset.txt | 1,367 | 512 | Error>(HttpResponse::Ok().cookie(cookie1).cookie(cookie2).finish())
}
}),
)
});
let request = srv.get("/").cookie(cookie1.clone()).cookie(cookie2.clone());
let response = request.send().await.unwrap();
assert!(response.status().is_success());
let c1 = response.c... |
rust_dataset_chunk_1368 | rust_dataset.txt | 1,368 | 512 | "local")]
async fn client_bearer_auth() {
let srv = actix_test::start(|| {
App::new().route(
"/",
web::to(|req: HttpRequest| {
if req
.headers()
.get(header::AUTHORIZATION)
.unwrap()
.to_... |
rust_dataset_chunk_1369 | rust_dataset.txt | 1,369 | 512 | ,
ssl::{SslAcceptor, SslConnector, SslMethod, SslVerifyMode},
x509::X509,
};
fn tls_config() -> SslAcceptor {
let rcgen::CertifiedKey { cert, signing_key } =
rcgen::generate_simple_self_signed(["localhost".to_owned()]).unwrap();
let cert_file = cert.pem();
let key_file = signing_key.seriali... |
rust_dataset_chunk_1370 | rust_dataset.txt | 1,370 | 512 | _success());
assert_eq!(response.version(), Version::HTTP_2);
}
--- FILE: actix-web/awc/tests/test_empty_stream.rs ---
use std::{convert::Infallible, time::Duration};
use actix_rt::net::TcpListener;
use awc::Client;
use bytes::Bytes;
use futures_util::stream;
use tokio::{
io::{AsyncReadExt as _, AsyncWriteEx... |
rust_dataset_chunk_1371 | rust_dataset.txt | 1,371 | 512 | n]);
if buf.len() > 32 * 1024 {
break;
}
}
}
let status = if has_chunked {
"400 Bad Request"
} else {
"200 OK"
};
let resp = format!("HTTP/1.1 {status}\r\nContent-Length: 0\r\nConnection: cl... |
rust_dataset_chunk_1372 | rust_dataset.txt | 1,372 | 512 | _server_cert(
&self,
_end_entity: &CertificateDer<'_>,
_intermediates: &[CertificateDer<'_>],
_server_name: &ServerName<'_>,
_ocsp_response: &[u8],
_now: UnixTime,
) -> Result<ServerCertVerified, rustls::Error> {
Ok(rustls::clie... |
rust_dataset_chunk_1373 | rust_dataset.txt | 1,373 | 512 | let protos = vec![b"h2".to_vec(), b"http/1.1".to_vec()];
config.alpn_protocols = protos;
// disable TLS verification
config
.dangerous()
.set_certificate_verifier(Arc::new(danger::NoCertificateVerification));
let client = awc::Client::builder()
.connector(awc::Connector::new()... |
rust_dataset_chunk_1374 | rust_dataset.txt | 1,374 | 512 | builder.set_private_key(&key).unwrap();
builder.set_alpn_select_callback(|_, protos| {
const H2: &[u8] = b"\x02h2";
if protos.windows(3).any(|window| window == H2) {
Ok(b"h2")
} else {
Err(openssl::ssl::AlpnError::NOACK)
}
});
builder.set_alpn_protos... |
rust_dataset_chunk_1375 | rust_dataset.txt | 1,375 | 512 | ::test(flavor = "local")]
async fn h2_streaming_body_does_not_send_transfer_encoding() {
let has_transfer_encoding = Arc::new(AtomicBool::new(false));
let has_transfer_encoding2 = Arc::clone(&has_transfer_encoding);
let srv = test_server(move || {
let has_transfer_encoding = Arc::clone(&has_transfe... |
rust_dataset_chunk_1376 | rust_dataset.txt | 1,376 | 512 | )),
ws::Frame::Text(text) => Ok(ws::Message::Text(
String::from_utf8(Vec::from(text.as_ref())).unwrap().into(),
)),
ws::Frame::Binary(bin) => Ok(ws::Message::Binary(bin)),
ws::Frame::Close(reason) => Ok(ws::Message::Close(reason)),
_ => Ok(ws::Message::Close(None)),
... |
rust_dataset_chunk_1377 | rust_dataset.txt | 1,377 | 512 | std::io::{Read as _, Write as _};
pub mod gzip {
use flate2::{read::GzDecoder, write::GzEncoder, Compression};
use super::*;
pub fn encode(bytes: impl AsRef<[u8]>) -> Vec<u8> {
let mut encoder = GzEncoder::new(Vec::new(), Compression::fast());
encoder.write_all(bytes.as_ref()).unwrap();
... |
rust_dataset_chunk_1378 | rust_dataset.txt | 1,378 | 512 | use ::zstd::stream::{read::Decoder, write::Encoder};
use super::*;
pub fn encode(bytes: impl AsRef<[u8]>) -> Vec<u8> {
let mut encoder = Encoder::new(Vec::new(), 3).unwrap();
encoder.write_all(bytes.as_ref()).unwrap();
encoder.finish().unwrap()
}
pub fn decode(bytes: impl AsR... |
rust_dataset_chunk_1379 | rust_dataset.txt | 1,379 | 512 | dev-dependencies]
actix-test = "0.1"
actix-web = "4"
env_logger = "0.11"
filetime = "0.2"
tempfile = "3.2"
tokio = { version = "1.51", features = ["macros", "rt"] }
[lints]
workspace = true
--- FILE: actix-web/actix-http/Cargo.toml ---
[package]
name = "actix-http"
version = "3.22.0"
authors = ["Nikolay Kim <fafhrd9... |
rust_dataset_chunk_1380 | rust_dataset.txt | 1,380 | 512 | -tls/openssl"]
# TLS via Rustls v0.20
rustls = ["__tls", "rustls-0_20"]
# TLS via Rustls v0.20
rustls-0_20 = ["__tls", "actix-tls/accept", "actix-tls/rustls-0_20"]
# TLS via Rustls v0.21
rustls-0_21 = ["__tls", "actix-tls/accept", "actix-tls/rustls-0_21"]
# TLS via Rustls v0.22
rustls-0_22 = ["__tls", "actix-tls/ac... |
rust_dataset_chunk_1381 | rust_dataset.txt | 1,381 | 512 | "0.2"
smallvec = "1.6.1"
tokio = { version = "1.38.2", features = ["net", "rt", "time"] }
tokio-util = { version = "0.7", features = ["io", "codec"] }
tracing = { version = "0.1.30", default-features = false, features = ["log"] }
# http2
h2 = { version = "0.3.27", optional = true }
# websockets
base64 = { version = ... |
rust_dataset_chunk_1382 | rust_dataset.txt | 1,382 | 512 | = "1.0"
static_assertions = "1"
tls-openssl = { package = "openssl", version = "0.10.55" }
tls-rustls_023 = { package = "rustls", version = "0.23" }
tokio = { version = "1.51", features = ["net", "rt", "macros", "sync", "time"] }
tokio-test = "0.4"
tokio-util = { version = "0.7", features = ["io", "codec", "time"] }
... |
rust_dataset_chunk_1383 | rust_dataset.txt | 1,383 | 512 | -service = "2"
actix-utils = "3"
awc = { version = "3.11", default-features = false }
bytes = "1"
futures-core = { version = "0.3.17", default-features = false }
http = "0.2.7"
log = "0.4"
serde = "1"
serde_json = "1"
serde_urlencoded = "0.7"
slab = "0.4"
socket2 = "0.6"
tls-openssl = { version = "0.10.55", package = ... |
rust_dataset_chunk_1384 | rust_dataset.txt | 1,384 | 512 | = "3"
actix-web = { version = "4", default-features = false }
derive_more = { version = "2", features = ["display", "error", "from"] }
futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] }
futures-util = { version = "0.3.17", default-features = false, features = ["alloc"] }
httparse = ... |
rust_dataset_chunk_1385 | rust_dataset.txt | 1,385 | 512 | = "0.24"
proc-macro2 = "1"
quote = "1"
syn = "3"
[lints]
workspace = true
--- FILE: actix-web/actix-router/Cargo.toml ---
[package]
name = "actix-router"
version = "0.5.5"
authors = [
"Nikolay Kim <fafhrd91@gmail.com>",
"Ali MJ Al-Nasrawy <alimjalnasrawy@gmail.com>",
"Rob Ede <robjtede@icloud.com>",
]
descrip... |
rust_dataset_chunk_1386 | rust_dataset.txt | 1,386 | 512 | 0.1.6"
authors = ["Nikolay Kim <fafhrd91@gmail.com>", "Rob Ede <robjtede@icloud.com>"]
description = "Integration testing tools for Actix Web applications"
keywords = ["http", "web", "framework", "async", "futures"]
homepage = "https://actix.rs"
repository = "https://github.com/actix/actix-web"
categories = [
"networ... |
rust_dataset_chunk_1387 | rust_dataset.txt | 1,387 | 512 | .7"
actix-http-test = "3"
actix-service = "2"
actix-utils = "3"
actix-web = { version = "4.6", default-features = false, features = ["cookies"] }
awc = { version = "3.11", default-features = false, features = ["cookies"] }
futures-core = { version = "0.3.17", default-features = false, features = ["std"] }
futures-util... |
rust_dataset_chunk_1388 | rust_dataset.txt | 1,388 | 512 | ",
]
[dependencies]
actix = { version = ">=0.12, <0.14", default-features = false }
actix-codec = "0.5"
actix-http = "3"
actix-web = { version = "4", default-features = false, features = ["ws"] }
bytes = "1"
bytestring = "1"
futures-core = { version = "0.3.17", default-features = false }
pin-project-lite = "0.2"
toki... |
rust_dataset_chunk_1389 | rust_dataset.txt | 1,389 | 512 | "cookies",
"secure-cookies",
]
[package.metadata.cargo_check_external_types]
allowed_external_types = [
"actix_http::*",
"actix_router::*",
"actix_rt::*",
"actix_server::*",
"actix_service::*",
"actix_utils::*",
"actix_web_codegen::*",
"bytes::*",
"cookie::*",
"cookie",
"futures_core::*",
"h... |
rust_dataset_chunk_1390 | rust_dataset.txt | 1,390 | 512 | 21", "actix-tls/accept", "actix-tls/rustls-0_21"]
# TLS via Rustls v0.22
rustls-0_22 = ["__tls", "actix-http/rustls-0_22", "actix-tls/accept", "actix-tls/rustls-0_22"]
# TLS via Rustls v0.23
rustls-0_23 = ["__tls", "actix-http/rustls-0_23", "actix-tls/accept", "actix-tls/rustls-0_23"]
# Full unicode support
unicode = ... |
rust_dataset_chunk_1391 | rust_dataset.txt | 1,391 | 512 | "2", features = ["as_ref", "deref", "deref_mut", "display", "error", "from"] }
encoding_rs = "0.8"
foldhash = "0.2"
futures-core = { version = "0.3.17", default-features = false }
futures-util = { version = "0.3.17", default-features = false }
impl-more = "0.3.1"
itoa = "1"
language-tags = "0.3"
log = "0.4"
mime = "0.... |
rust_dataset_chunk_1392 | rust_dataset.txt | 1,392 | 512 | { version = "1.51", features = ["rt-multi-thread", "macros", "time"] }
tokio-util = { version = "0.7", default-features = false, features = ["time"] }
zstd = "0.14"
[lints]
workspace = true
[[test]]
name = "test_server"
required-features = ["compress-brotli", "compress-gzip", "compress-zstd", "cookies"]
[[test]]
na... |
rust_dataset_chunk_1393 | rust_dataset.txt | 1,393 | 512 | = true
--- FILE: actix-web/awc/Cargo.toml ---
[package]
name = "awc"
version = "3.11.0"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Async HTTP and WebSocket client library"
keywords = ["actix", "http", "framework", "async", "web"]
categories = [
"network-programming",
"asynchronous",
"w... |
rust_dataset_chunk_1394 | rust_dataset.txt | 1,394 | 512 | )
rustls-0_22-webpki-roots = ["tls-rustls-0_22", "actix-tls/rustls-0_22-webpki-roots"]
# TLS via Rustls v0.22 (Native roots)
rustls-0_22-native-roots = ["tls-rustls-0_22", "actix-tls/rustls-0_22-native-roots"]
# TLS via Rustls v0.23
rustls-0_23 = ["tls-rustls-0_23", "actix-tls/rustls-0_23"]
# TLS via Rustls v0.23 (WebP... |
rust_dataset_chunk_1395 | rust_dataset.txt | 1,395 | 512 | -features = false }
actix-service = "2"
actix-tls = { version = "3.4", features = ["connect", "uri"] }
actix-utils = "3"
base64 = "0.23"
bytes = "1"
cfg-if = "1"
derive_more = { version = "2", features = ["display", "error", "from"] }
futures-core = { version = "0.3.17", default-features = false, features = ["alloc"] ... |
rust_dataset_chunk_1396 | rust_dataset.txt | 1,396 | 512 | "rustls-0_23"] }
actix-tls = { version = "3.4", features = ["openssl", "rustls-0_23"] }
actix-utils = "3"
actix-web = { version = "4.13", features = ["openssl"] }
brotli = "9"
const-str = "1.1"
env_logger = "0.11"
flate2 = "1.0.13"
futures-util = { version = "0.3.17", default-features = false }
static_assertions = "1... |
rust_dataset_chunk_1397 | rust_dataset.txt | 1,397 | 512 | " }
actix-multipart-derive = { path = "actix-multipart-derive" }
actix-router = { path = "actix-router" }
actix-test = { path = "actix-test" }
actix-web = { path = "actix-web" }
actix-web-codegen = { path = "actix-web-codegen" }
awc = { path = "awc" }
# uncomment for quick testing against local actix-net repo
# actix-... |
rust_dataset_chunk_1398 | rust_dataset.txt | 1,398 | 512 | "BSD-2-Clause",
"BSD-3-Clause",
"Zlib",
"OpenSSL",
"MPL-2.0"
]
private = { ignore = true }
# FIXME: old rustls introduces old ring which is not set license field properly.
[[licenses.clarify]]
crate = "ring"
expression = "MIT AND ISC AND OpenSSL"
license-files = [
{ path = "LICENSE", hash = 0xbd0e... |
rust_dataset_chunk_1399 | rust_dataset.txt | 1,399 | 512 | 0.21 require webpki-roots 0.22 and 0.25, which have no patched releases." },
{ id = "RUSTSEC-2026-0382", reason = "Legacy rustls 0.21 and 0.22 require rustls-webpki 0.101 and 0.102, which have no patched releases." },
]
--- FILE: actix-web/.release-plz.toml ---
[workspace]
changelog_update = false
dependencies_up... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.