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_1200
rust_dataset.txt
1,200
512
// allow deprecated App::data #[allow(deprecated)] #[tokio::test(flavor = "local")] async fn test_config_recall_locations() { async fn bytes_handler(_: Bytes) -> impl Responder { "payload is probably json bytes" } async fn string_handler(_: String) -> impl Responder ...
rust_dataset_chunk_1201
rust_dataset.txt
1,201
512
ContentType(mime::APPLICATION_JSON)) .to_request(); let resp = call_service(&srv, req).await; assert_eq!(resp.status(), StatusCode::OK); let req = TestRequest::with_uri("/string-app-data") .insert_header(header::ContentType(mime::APPLICATION_JSON)) .to_reques...
rust_dataset_chunk_1202
rust_dataset.txt
1,202
512
unwrap() { PayloadError::Overflow => {} _ => unreachable!("error"), } let (req, mut pl) = TestRequest::default() .set_payload(Bytes::from_static(b"test")) .to_http_parts(); let res = HttpMessageBody::new(&req, &mut pl).await; assert_eq!(re...
rust_dataset_chunk_1203
rust_dataset.txt
1,203
512
-> String { /// format!("Authorization request for id={} and type={:?}!", info.id, info.response_type) /// } /// /// // To access the entire underlying query struct, use `.into_inner()`. /// #[get("/debug1")] /// async fn debug1(info: web::Query<AuthRequest>) -> String { /// dbg!("Authorization object = {:?}",...
rust_dataset_chunk_1204
rust_dataset.txt
1,204
512
here](#Examples) for example of usage as an extractor. #[expect(deprecated, reason = "preserve the public ready future type")] impl<T: DeserializeOwned> FromRequest for Query<T> { type Error = Error; type Future = Ready<Result<Self, Error>>; #[inline] fn from_request(req: &HttpRequest, _: &mut Payload)...
rust_dataset_chunk_1205
rust_dataset.txt
1,205
512
self.err_handler = Some(Arc::new(f)); self } } #[cfg(test)] mod tests { use actix_http::StatusCode; use derive_more::Display; use serde::Deserialize; use super::*; use crate::{error::InternalError, test::TestRequest, HttpResponse}; #[derive(Deserialize, Debug, Display)] ...
rust_dataset_chunk_1206
rust_dataset.txt
1,206
512
(); Query::<(u32, u32)>::from_request(&req, &mut pl) .await .unwrap(); } #[tokio::test(flavor = "local")] async fn test_custom_error_responder() { let req = TestRequest::with_uri("/name/user1/") .app_data(QueryConfig::default().error_handler(|e, _| { ...
rust_dataset_chunk_1207
rust_dataset.txt
1,207
512
256kB. pub fn limit(mut self, limit: usize) -> Self { self.limit = limit; self } fn err(err: ReadlinesError) -> Self { Readlines { stream: Payload::None, buf: BytesMut::new(), limit: 262_144, checked_buff: true, encoding: ...
rust_dataset_chunk_1208
rust_dataset.txt
1,208
512
true; } // poll req for more bytes match ready!(Pin::new(&mut this.stream).poll_next(cx)) { Some(Ok(mut bytes)) => { // check if there is a newline in bytes let mut found: Option<usize> = None; for (ind, b) in bytes.iter().enumerate()...
rust_dataset_chunk_1209
rust_dataset.txt
1,209
512
stream = Readlines::new(&mut req); assert_eq!( stream.next().await.unwrap().unwrap(), "Lorem Ipsum is simply dummy text of the printing and typesetting\n" ); assert_eq!( stream.next().await.unwrap().unwrap(), "industry. Lorem Ipsum has been the i...
rust_dataset_chunk_1210
rust_dataset.txt
1,210
512
-to-clone application data item //! - [`ReqData`]: Request-local data item //! - [`Path`]: URL path parameters / dynamic segments //! - [`Query`]: URL query parameters //! - [`Header`]: Typed header //! - [`Json`]: JSON payload //! - [`Form`]: URL-encoded payload //! - [`Bytes`]: Raw payload //! //! # Responders //! - ...
rust_dataset_chunk_1211
rust_dataset.txt
1,211
512
MethodNotAllowed())) /// ); /// ``` pub fn resource<T: IntoPatterns>(path: T) -> Resource { Resource::new(path) } /// Creates scope for common path prefix. /// /// Scopes collect multiple paths under a common path prefix. The scope's path can contain dynamic /// path segments. /// /// # Avoid Trailing Slashes /// ...
rust_dataset_chunk_1212
rust_dataset.txt
1,212
512
method_route!(get, GET); method_route!(post, POST); method_route!(put, PUT); method_route!(patch, PATCH); method_route!(delete, DELETE); method_route!(head, HEAD); method_route!(trace, TRACE); /// Creates a new route with `QUERY` method guard. /// /// # Examples /// /// In this example, one `QUERY /{project_id}` route...
rust_dataset_chunk_1213
rust_dataset.txt
1,213
512
fn to<F, Args>(handler: F) -> Route where F: Handler<Args>, Args: FromRequest + 'static, F::Output: Responder + 'static, { Route::new().to(handler) } /// Creates a raw service for a specific path. /// /// ``` /// use actix_web::{dev, web, guard, App, Error, HttpResponse}; /// /// async fn my_service(r...
rust_dataset_chunk_1214
rust_dataset.txt
1,214
512
: &[u8] = include_bytes!("fixtures/lorem.txt.gz"); static LOREM_BR: &[u8] = include_bytes!("fixtures/lorem.txt.br"); static LOREM_ZSTD: &[u8] = include_bytes!("fixtures/lorem.txt.zst"); static LOREM_XZ: &[u8] = include_bytes!("fixtures/lorem.txt.xz"); macro_rules! test_server { () => { actix_test::start(||...
rust_dataset_chunk_1215
rust_dataset.txt
1,215
512
assert_eq!(res.status(), StatusCode::OK); assert_eq!(res.headers().get(header::CONTENT_ENCODING), None); let bytes = res.body().await.unwrap(); assert_eq!(bytes, Bytes::from_static(LOREM)); srv.stop().await; } #[tokio::test(flavor = "local")] async fn negotiate_encoding_gzip() { let srv = tes...
rust_dataset_chunk_1216
rust_dataset.txt
1,216
512
.body().await.unwrap(); assert_eq!(bytes, Bytes::from_static(LOREM)); // check that returned content is actually brotli encoded let mut res = srv .post("/static") .no_decompress() .insert_header((header::ACCEPT_ENCODING, "br, zstd, gzip")) .send() .await .un...
rust_dataset_chunk_1217
rust_dataset.txt
1,217
512
don't decompress response body .no_decompress() // signal that we want a compressed body .insert_header((header::ACCEPT_ENCODING, "gzip, br;q=0.8, zstd;q=0.5")) .send(); let mut res = req.await.unwrap(); assert_eq!(res.status(), StatusCode::OK); assert_eq!(res.headers().get...
rust_dataset_chunk_1218
rust_dataset.txt
1,218
512
mut res = req.await.unwrap(); assert_eq!(res.status(), StatusCode::OK); assert_eq!(res.headers().get(header::CONTENT_ENCODING).unwrap(), "br"); let bytes = res.body().await.unwrap(); assert_eq!(bytes, Bytes::from_static(LOREM_BR)); srv.stop().await; } // Regression test for https://github.com/ac...
rust_dataset_chunk_1219
rust_dataset.txt
1,219
512
.insert_header((header::ACCEPT_ENCODING, "xz, identity;q=0")) .send(); let mut res = req.await.unwrap(); assert_eq!(res.status(), StatusCode::OK); assert_eq!(res.headers().get(header::CONTENT_ENCODING).unwrap(), "xz"); let bytes = res.body().await.unwrap(); assert_eq!(bytes, Bytes...
rust_dataset_chunk_1220
rust_dataset.txt
1,220
512
(web::get().to(HttpResponse::Ok)), ) .service( web::scope("/scoped") .guard(guard::Header("x-scope", "1")) .configure(|cfg| { cfg.external_resource("scope-external", "https://scope.example/{id}"); ...
rust_dataset_chunk_1221
rust_dataset.txt
1,221
512
"); let alpha_guard_details = alpha .get("guards_detail") .and_then(|v| v.as_array()) .expect("Alpha guards_detail missing"); assert!(alpha_guards.is_empty()); assert!(!alpha_guard_details.is_empty()); let scoped = find_item(&items, "/scoped"); assert_eq!( scoped.get...
rust_dataset_chunk_1222
rust_dataset.txt
1,222
512
Service, ServiceRequest, ServiceResponse, Transform}, get, http::{header, StatusCode}, middleware::{from_fn, Next}, test::{call_service, init_service, TestRequest}, web, App, Error, HttpResponse, ResponseError, }; use futures_core::future::LocalBoxFuture; use futures_util::lock::Mutex; #[derive(De...
rust_dataset_chunk_1223
rust_dataset.txt
1,223
512
lock.lock().await = Some(success.response().error().is_some()); } response }) } } #[tokio::test(flavor = "local")] async fn error_cause_should_be_propagated_to_middlewares() { let lock = Arc::new(Mutex::new(None)); let spy_middleware = SpyMiddleware(lock.clone()); let a...
rust_dataset_chunk_1224
rust_dataset.txt
1,224
512
::Ok)) }); let res = srv .get("/") .insert_header((header::ORIGIN, "https://example.com")) .send() .await .unwrap(); assert_eq!(res.status(), StatusCode::BAD_REQUEST); assert_eq!( res.headers().get(header::ACCESS_CONTROL_ALLOW_ORIGIN), Some(&head...
rust_dataset_chunk_1225
rust_dataset.txt
1,225
512
!("{}", addr)) .unwrap() .run(); tx.send(srv.handle()).unwrap(); srv.await }) .unwrap(); }); let srv = rx.recv().unwrap(); let client = awc::Client::builder() .connector(awc::Connector::new().timeout(Duration...
rust_dataset_chunk_1226
rust_dataset.txt
1,226
512
slow_body = stream::unfold(0, |idx| async move { if idx < 8 { sleep(Duration::from_millis(200)).await; Some((Ok::<_, Infallible>(Bytes::from_static(b" ")), idx + 1)) } else { None } }); let client = awc::Client::defaul...
rust_dataset_chunk_1227
rust_dataset.txt
1,227
512
(move || { queued_request_started.store(true, Ordering::SeqCst); async { HttpResponse::Ok().finish() } }), ) }) .workers(1) // Keep these timeouts above the test assertions so they cannot cause EOF. .keep_alive(Duration::from_secs(30)) ...
rust_dataset_chunk_1228
rust_dataset.txt
1,228
512
let idle_connection_closed = timeout(Duration::from_millis(500), idle_connection.read(&mut buf)).await; // Allow the current request, but not its queued successor, to finish during shutdown. finish_request.notify_one(); let response = timeout( Duration::from_millis(500), read_h...
rust_dataset_chunk_1229
rust_dataset.txt
1,229
512
and leave the connection idle in HTTP/1 keep-alive. let mut connection = TcpStream::connect(addr).await.unwrap(); connection .write_all(b"GET / HTTP/1.1\r\nhost: localhost\r\n\r\n") .await .unwrap(); let response = read_http1_response_head(&mut connection).await.unwrap(); assert...
rust_dataset_chunk_1230
rust_dataset.txt
1,230
512
ssl_acceptor(); let srv = HttpServer::new(|| { App::new().service(web::resource("/").route(web::to(|req: HttpRequest| { assert!(req.app_config().secure()); async { HttpResponse::Ok().body("test") } }))) ...
rust_dataset_chunk_1231
rust_dataset.txt
1,231
512
srv = match nodelay { Some(enabled) => srv.tcp_nodelay(enabled), None => srv, }; let srv = srv .on_connect(move |io, ext| { if let Some(io) = io.downcast_ref::<actix_web::rt::net::TcpStream>() { ...
rust_dataset_chunk_1232
rust_dataset.txt
1,232
512
await .unwrap(); assert!(response.status().is_success()); srv.stop(false).await; } #[tokio::test(flavor = "local")] async fn test_tcp_nodelay_default() { assert_tcp_nodelay_config(None).await; } #[cfg(feature = "http2")] #[tokio::test(flavor = "local")] async fn test_plaintext_protocol_selection...
rust_dataset_chunk_1233
rust_dataset.txt
1,233
512
(&head, b"HTTP/1.1 "); } drop(stream); handle.stop(false).await; task.await.unwrap().unwrap(); } } --- FILE: actix-web/actix-web/tests/test-macro-import-conflict.rs --- //! Checks that test macro does not cause problems in the presence of imports named "test" that //! could be eit...
rust_dataset_chunk_1234
rust_dataset.txt
1,234
512
signing_key.serialize_pem(); let cert = X509::from_pem(cert_file.as_bytes()).unwrap(); let key = PKey::private_key_from_pem(key_file.as_bytes()).unwrap(); let mut builder = SslAcceptor::mozilla_intermediate(SslMethod::tls()).unwrap(); builder.set_certificate(&cert).unwrap(); builder.set_private_k...
rust_dataset_chunk_1235
rust_dataset.txt
1,235
512
.unwrap(); assert_eq!(bytes, Bytes::from_static(STR.as_ref())); srv.stop().await; } // enforcing an encoding per-response is removed // #[tokio::test(flavor = "local")] // async fn test_body_encoding_override() { // let srv = actix_test::start_with(actix_test::config().h1(), || { // App::new() // ...
rust_dataset_chunk_1236
rust_dataset.txt
1,236
512
async move { HttpResponse::Ok().body(data.clone()) } }))) }); let mut res = srv .get("/") .no_decompress() .append_header((header::ACCEPT_ENCODING, "gzip")) .send() .await .unwrap(); assert_eq!(res.status(), StatusCode::OK); l...
rust_dataset_chunk_1237
rust_dataset.txt
1,237
512
::gzip::decode(bytes), STR.as_bytes()); srv.stop().await; } #[tokio::test(flavor = "local")] async fn test_body_br_streaming() { let srv = actix_test::start_with(actix_test::config().h1(), || { App::new() .wrap(Compress::default()) .service(web::resource("/").route(web::to(|| a...
rust_dataset_chunk_1238
rust_dataset.txt
1,238
512
ing() { let srv = actix_test::start_with(actix_test::config().h1(), || { App::new().service(web::resource("/").route(web::to(move || async { HttpResponse::Ok() .no_chunking(STR.len() as u64) .streaming(TestBody::new(Bytes::from_static(STR.as_ref()), 24)) }...
rust_dataset_chunk_1239
rust_dataset.txt
1,239
512
{ let srv = actix_test::start_with(actix_test::config().h1(), || { App::new().wrap(Compress::default()).service( web::resource("/").route(web::to(move || async { HttpResponse::Ok().body(STR) })), ) }); let mut res = srv .get("/") .append_header((header::ACCEPT_E...
rust_dataset_chunk_1240
rust_dataset.txt
1,240
512
")] async fn test_zstd_encoding_large() { let data = Alphanumeric.sample_string(&mut rand::rng(), 320_000); let srv = actix_test::start_with(actix_test::config().h1(), || { App::new().service( web::resource("/") .app_data(web::PayloadConfig::new(320_000)) .ro...
rust_dataset_chunk_1241
rust_dataset.txt
1,241
512
.body().await.unwrap(); assert_eq!(bytes, STR.as_bytes()); srv.stop().await; } #[tokio::test(flavor = "local")] async fn test_gzip_encoding_large() { let data = STR.repeat(10); let srv = actix_test::start_with(actix_test::config().h1(), || { App::new().service(web::resource("/").route(web::to(...
rust_dataset_chunk_1242
rust_dataset.txt
1,242
512
assert_eq!(bytes, Bytes::from_static(STR.as_ref())); srv.stop().await; } #[tokio::test(flavor = "local")] async fn test_reading_deflate_encoding_large() { let data = STR.repeat(10); let srv = actix_test::start_with(actix_test::config().h1(), || { App::new().service(web::resource("/").route(web...
rust_dataset_chunk_1243
rust_dataset.txt
1,243
512
_eq!(res.status(), StatusCode::OK); let bytes = res.body().await.unwrap(); assert_eq!(bytes, Bytes::from_static(STR.as_ref())); srv.stop().await; } #[tokio::test(flavor = "local")] async fn test_brotli_encoding_large() { let data = Alphanumeric.sample_string(&mut rand::rng(), 320_000); let srv =...
rust_dataset_chunk_1244
rust_dataset.txt
1,244
512
Config}; use rustls_pki_types::PrivatePkcs8KeyDer; use super::*; fn tls_config() -> RustlsServerConfig { let rcgen::CertifiedKey { cert, signing_key } = rcgen::generate_simple_self_signed(["localhost".to_owned()]).unwrap(); let cert_chain = vec![cert.der().clone()]; let...
rust_dataset_chunk_1245
rust_dataset.txt
1,245
512
().await.unwrap(); assert!(res.status().is_success()); { let first_cookie = Cookie::build("first", "first_value") .http_only(true) .finish(); let second_cookie = Cookie::new("second", "first_value"); let cookies = res.cookies().expect("To have cookies"); ...
rust_dataset_chunk_1246
rust_dataset.txt
1,246
512
= actix_test::start_with(actix_test::config().h1(), || { App::new() .wrap(NormalizePath::new(TrailingSlash::Trim)) .service(web::resource("/one").route(web::to(HttpResponse::Ok))) }); let res = srv.get("/one/").send().await.unwrap(); assert_eq!(res.status(), StatusCode::OK)...
rust_dataset_chunk_1247
rust_dataset.txt
1,247
512
identity;q=0")) .no_decompress() .send() .await .unwrap(); assert_eq!(res.status(), StatusCode::NOT_ACCEPTABLE); assert_eq!(res.headers().get(header::CONTENT_ENCODING), None); let bytes = res.body().await.unwrap(); // body should contain the supported encodings ass...
rust_dataset_chunk_1248
rust_dataset.txt
1,248
512
TestRequest::post() .insert_header((header::CONTENT_ENCODING, "zstd")) .insert_header((header::CONTENT_TYPE, "application/x-www-form-urlencoded")) .to_request(); *req.payload() = Payload::from(stream.boxed_local()); let res = test::call_service(&app, req).await; // Assert that the ...
rust_dataset_chunk_1249
rust_dataset.txt
1,249
512
.to_str().unwrap_or("")) .unwrap_or("") .contains("chunked"); assert!( !has_chunked, "chunked should not be used when Content-Length is provided" ); assert_eq!( resp.headers().get(header::CONTENT_TYPE), Some(&HeaderValue::from_static("application/octet-strea...
rust_dataset_chunk_1250
rust_dataset.txt
1,250
512
let y = &x; // receiver.await.unwrap(); // let _z = **y; // Ok::<_, ()>(Bytes::new()) // }))); // let waker = noop_waker(); // let mut cx = Context::from_waker(&waker); // let _ = body_stream.as_mut().unwrap().poll_next(&mut cx); // sender.send(()).unwrap(); // ...
rust_dataset_chunk_1251
rust_dataset.txt
1,251
512
-> Vec<u8> { let mut encoder = BrotliEncoder::new( Vec::new(), 8 * 1024, // 32 KiB buffer 3, // BROTLI_PARAM_QUALITY 22, // BROTLI_PARAM_LGWIN ); encoder.write_all(bytes.as_ref()).unwrap(); encoder.flush().unwrap(); en...
rust_dataset_chunk_1252
rust_dataset.txt
1,252
512
_next(&mut cx); // sender.send(()).unwrap(); // let _ = std::mem::replace(&mut body_stream, Err([0; 32])) // .unwrap() // .poll_next(&mut cx); // } --- FILE: actix-web/awc/examples/client.rs --- //! Demonstrates construction and usage of a TLS-capable HTTP client. extern crate tls_rustls_0_23...
rust_dataset_chunk_1253
rust_dataset.txt
1,253
512
in-memory response body. Bytes { body: Bytes }, /// Generic / Other message body. Body { #[pin] body: B }, } } impl AnyBody { /// Constructs a "body" representing an empty response. pub fn none() -> Self { Self::None } /// Constructs a new, 0-length body. pub ...
rust_dataset_chunk_1254
rust_dataset.txt
1,254
512
body } => AnyBody::new_boxed(body), } } } impl<B> MessageBody for AnyBody<B> where B: MessageBody, { type Error = crate::BoxError; fn size(&self) -> BodySize { match self { AnyBody::None => BodySize::None, AnyBody::Bytes { ref body } => BodySize::Sized(body.len...
rust_dataset_chunk_1255
rust_dataset.txt
1,255
512
BoxError; fn size(&self) -> BodySize { unimplemented!() } fn poll_next( self: Pin<&mut Self>, _cx: &mut Context<'_>, ) -> Poll<Option<Result<Bytes, Self::Error>>> { unimplemented!() } } assert_impl_all!(AnyBody<()>: Send,...
rust_dataset_chunk_1256
rust_dataset.txt
1,256
512
enabled and neither `rustls-0_23-native-roots` nor /// `rustls-0_23-webpki-roots` are enabled, this ClientBuilder will build without TLS. In order /// to enable TLS in this scenario, a custom `Connector` _must_ be added to the builder before /// finishing construction. #[allow(clippy::new_ret_no_self)]...
rust_dataset_chunk_1257
rust_dataset.txt
1,257
512
} /// Disable request timeout. pub fn disable_timeout(mut self) -> Self { self.timeout = None; self } /// Set local IP Address the connector would use for establishing connection. pub fn local_address(mut self, addr: IpAddr) -> Self { self.local_address = Some(addr); ...
rust_dataset_chunk_1258
rust_dataset.txt
1,258
512
_into_pair() { Ok((key, value)) => self.default_headers.append(key, value), Err(err) => panic!("Header error: {:?}", err.into()), } self } #[doc(hidden)] #[deprecated(since = "3.0.0", note = "Prefer `add_default_header((key, value))`.")] pub fn header<K, V>(mut ...
rust_dataset_chunk_1259
rust_dataset.txt
1,259
512
::new(self.middleware, mw), fundamental_headers: self.fundamental_headers, max_http_version: self.max_http_version, stream_window_size: self.stream_window_size, conn_window_size: self.conn_window_size, default_headers: self.default_headers, timeout...
rust_dataset_chunk_1260
rust_dataset.txt
1,260
512
dvcmQ=" ); let client = ClientBuilder::new().basic_auth("username", None); assert_eq!( client .default_headers .get(header::AUTHORIZATION) .unwrap() .to_str() .unwrap(), "Basic dXNlcm5hbWU6" ...
rust_dataset_chunk_1261
rust_dataset.txt
1,261
512
::{ io, ops::{Deref, DerefMut}, pin::Pin, task::{Context, Poll}, time, }; use actix_codec::{AsyncRead, AsyncWrite, Framed, ReadBuf}; use actix_http::{body::MessageBody, h1::ClientCodec, Payload, RequestHeadType, ResponseHead}; use actix_rt::task::JoinHandle; use bytes::Bytes; use futures_core::futu...
rust_dataset_chunk_1262
rust_dataset.txt
1,262
512
1Connection<Io> { fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll<io::Result<usize>> { self.io_pin_mut().poll_write(cx, buf) } fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<io::Result<()>> { self.io_pin_mut().p...
rust_dataset_chunk_1263
rust_dataset.txt
1,263
512
.release(ConnectionInnerType::H2(io), self.created); } } /// `H2ConnectionInner` has two parts: `SendRequest` and `Connection`. /// /// `Connection` is spawned as an async task on runtime and `H2ConnectionInner` holds a handle /// for this task. Therefore, it can wake up and quit the task when SendReq...
rust_dataset_chunk_1264
rust_dataset.txt
1,264
512
pub(super) fn from_h1(io: Io, created: time::Instant, acquired: Acquired<Io>) -> Self { Self::H1(H1Connection { io: Some(io), created, acquired, }) } pub(super) fn from_h2( io: H2ConnectionInner, created: time::Instant, acquired: Acqu...
rust_dataset_chunk_1265
rust_dataset.txt
1,265
512
, framed) = h1proto::open_tunnel(self, head.into()).await?; Ok((head, framed)) } Connection::Tls(ConnectionType::H2(mut conn)) => { conn.release(); Err(SendRequestError::TunnelNotSupported) } Conn...
rust_dataset_chunk_1266
rust_dataset.txt
1,266
512
: &mut Context<'_>) -> Poll<io::Result<()>> { match self.get_mut() { Connection::Tcp(ConnectionType::H1(conn)) => Pin::new(conn).poll_shutdown(cx), Connection::Tls(ConnectionType::H1(conn)) => Pin::new(conn).poll_shutdown(cx), _ => unreachable!("{}", H2_UNREACHABLE_WRITE), ...
rust_dataset_chunk_1267
rust_dataset.txt
1,267
512
.sender) .ready() .await .is_ok()); drop(conn); /// Periodically polls a retained sender until it observes the closed H2 connection. struct DropCheck { sender: h2::client::SendRequest<Bytes>, interval: Interval, start_from...
rust_dataset_chunk_1268
rust_dataset.txt
1,268
512
reexports::SslConnector), /// Provided because building the OpenSSL context on newer versions can be very slow. /// This prevents unnecessary calls to `.build()` while constructing the client connector. #[cfg(feature = "openssl")] #[allow(dead_code)] // false positive; used in build_tls OpensslBuil...
rust_dataset_chunk_1269
rust_dataset.txt
1,269
512
_23-native-roots` features are enabled /// and no default crypto provider has been loaded, this method will panic. /// - When the `rustls-0_23-native-roots` or `rustls-0_22-native-roots` features are enabled /// and the runtime system has no native root certificates, this method will panic. #[allow(...
rust_dataset_chunk_1270
rust_dataset.txt
1,270
512
-native-roots"))] { /// Build TLS connector with Rustls v0.22, based on supplied ALPN protocols. fn build_tls(protocols: Vec<Vec<u8>>) -> OurTlsConnector { use actix_tls::connect::rustls_0_22::{self, reexports::ClientConfig}; cfg_if::cfg_if! { ...
rust_dataset_chunk_1271
rust_dataset.txt
1,271
512
::sync::Arc::new(config)) } } else if #[cfg(feature = "openssl")] { /// Build TLS connector with OpenSSL, based on supplied ALPN protocols. fn build_tls(protocols: Vec<Vec<u8>>) -> OurTlsConnector { use actix_tls::connect::openssl::reexports::{SslConnector, Ss...
rust_dataset_chunk_1272
rust_dataset.txt
1,272
512
+ Clone + 'static, { /// Sets TCP connection timeout. /// /// This is the max time allowed to connect to remote host, including DNS name resolution. /// /// By default, the timeout is 5 seconds. pub fn timeout(mut self, timeout: Duration) -> Self { self.config.timeout = t...
rust_dataset_chunk_1273
rust_dataset.txt
1,273
512
} /// Sets custom Rustls v0.22 `ClientConfig` instance. #[cfg(any( feature = "rustls-0_22-webpki-roots", feature = "rustls-0_22-native-roots", ))] pub fn rustls_0_22( mut self, connector: std::sync::Arc<actix_tls::connect::rustls_0_22::reexports::ClientConfig>, ) ->...
rust_dataset_chunk_1274
rust_dataset.txt
1,274
512
self } /// Sets the initial window size (in bytes) for HTTP/2 connection-level flow control for /// received data. /// /// The default value is 65,535 and is good for APIs, but not for big objects. pub fn initial_connection_window_size(mut self, size: u32) -> Self { self.config.conn_wi...
rust_dataset_chunk_1275
rust_dataset.txt
1,275
512
Connector` builder always concludes by calling `finish()` last in its combinator chain. pub fn finish(self) -> ConnectorService<S, IO> { let local_address = self.config.local_address; let timeout = self.config.timeout; let tcp_service_inner = TcpConnectorInnerService::new(self.c...
rust_dataset_chunk_1276
rust_dataset.txt
1,276
512
= TlsConnectorService { tcp_service: tcp_service_inner, tls_service: NoOpTlsConnectorService, timeout: handshake_timeout, }; Some(actix_service::boxed::rc_service(tls_service)) } ...
rust_dataset_chunk_1277
rust_dataset.txt
1,277
512
any(|w| w == H2)); if h2 { (Box::new(sock), Protocol::Http2) } else { (Box::new(sock), Protocol::Http1) } } } let handshake_timeout = self...
rust_dataset_chunk_1278
rust_dataset.txt
1,278
512
Stream<Io>> { fn into_connection_io(self) -> (Box<dyn ConnectionIo>, Protocol) { let sock = self.into_parts().0; let h2 = sock .get_ref() .1 .alpn_protocol() ...
rust_dataset_chunk_1279
rust_dataset.txt
1,279
512
::new(tls_service, tls_config)); ConnectorServicePriv { tcp_pool, tls_pool } } } /// tcp service for map `TcpConnection<Uri, Io>` type to `(Io, Protocol)` #[derive(Clone)] pub struct TcpConnectorService<S: Clone> { service: S, } impl<S, Io> Service<Connect> for TcpConnectorService<S> where S: Ser...
rust_dataset_chunk_1280
rust_dataset.txt
1,280
512
tls_service: Tls, timeout: Duration, } #[cfg(any( feature = "dangerous-h2c", feature = "openssl", feature = "rustls-0_20", feature = "rustls-0_21", feature = "rustls-0_22-webpki-roots", feature = "rustls-0_22-native-roots", feature = "rustls-0_23", ))] impl<Tcp, Tls, IO> Service<Co...
rust_dataset_chunk_1281
rust_dataset.txt
1,281
512
ConnectorFuture<S, Fut1, Fut2> where S: Service<TcpConnection<Uri, Io>, Response = Res, Error = std::io::Error, Future = Fut2>, S::Response: IntoConnectionIo, Fut1: Future<Output = Result<TcpConnection<Uri, Io>, ConnectError>>, Fut2: Future<Output = Result<S::Response, S::Error>>, Io: ConnectionIo, ...
rust_dataset_chunk_1282
rust_dataset.txt
1,282
512
-> Self::Future { let mut req = ConnectInfo::new(req.uri).set_addr(req.addr); if let Some(local_addr) = self.local_address { req = req.set_local_addr(local_addr); } TcpConnectorInnerFuture { fut: self.service.call(req), timeout: sleep(self.timeout),...
rust_dataset_chunk_1283
rust_dataset.txt
1,283
512
(Io1, Protocol), Error = ConnectError> + Clone + 'static, S2: Service<Connect, Response = (Io2, Protocol), Error = ConnectError> + Clone + 'static, Io1: ConnectionIo, Io2: ConnectionIo, { type Response = Connection<Io1, Io2>; type Error = ConnectError; type Future = ConnectorServiceFuture<S1, S...
rust_dataset_chunk_1284
rust_dataset.txt
1,284
512
+ 'static, S2: Service<Connect, Response = (Io2, Protocol), Error = ConnectError> + Clone + 'static, Io1: ConnectionIo, Io2: ConnectionIo, { type Output = Result<Connection<Io1, Io2>, ConnectError>; fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { match self.proj...
rust_dataset_chunk_1285
rust_dataset.txt
1,285
512
ory dns resolver. HICKORY_DNS_RESOLVER.with(|local| { local .get_or_init(|| { let (cfg, opts) = match read_system_conf() { Ok((cfg, opts)) => (cfg, opts), Err(err) => { log::error!("Hickor...
rust_dataset_chunk_1286
rust_dataset.txt
1,286
512
, Display, From)] #[non_exhaustive] pub enum ConnectError { /// SSL feature is not enabled #[display("SSL is not supported")] SslIsNotSupported, /// SSL error #[cfg(feature = "openssl")] #[display("{}", _0)] SslError(OpensslError), /// Failed to resolve the hostname #[display("Fail...
rust_dataset_chunk_1287
rust_dataset.txt
1,287
512
{}", _0)] Url(InvalidUrl), /// Failed to connect to host #[display("Failed to connect to host: {}", _0)] Connect(ConnectError), /// Error sending request Send(io::Error), /// Error parsing response Response(ParseError), /// Http error #[display("{}", _0)] Http(HttpError)...
rust_dataset_chunk_1288
rust_dataset.txt
1,288
512
StatusCode, }; use actix_utils::future::poll_fn; use bytes::{buf::BufMut, Bytes, BytesMut}; use futures_core::{ready, Stream}; use futures_util::SinkExt as _; use pin_project_lite::pin_project; use super::{ connection::{ConnectionIo, H1Connection}, error::{ConnectError, SendRequestError}, }; use crate::BoxErr...
rust_dataset_chunk_1289
rust_dataset.txt
1,289
512
!(wrt, "{}:{}", host, port)?, }; match wrt.get_mut().split().freeze().try_into_value() { Ok(value) => match head { RequestHeadType::Owned(ref mut head) => { head.headers.insert(HOST, value); } Re...
rust_dataset_chunk_1290
rust_dataset.txt
1,290
512
.as_mut().flush(cx)).await?; } _ => send_body(body.as_mut(), pin_framed.as_mut(), first_chunk).await?, }; // read response and init read body let head = poll_fn(|cx| pin_framed.as_mut().poll_next(cx)) .await .ok_or(ConnectError::Disconnected)??; ...
rust_dataset_chunk_1291
rust_dataset.txt
1,291
512
().write(h1::Message::Chunk(Some(chunk)))?; } Some(Err(err)) => return Err(SendRequestError::Body(err.into())), None => { eof = true; framed.as_mut().write(h1::Message::Chunk(None))?; } } } ...
rust_dataset_chunk_1292
rust_dataset.txt
1,292
512
; use h2::{ client::{Builder, Connection, SendRequest}, SendStream, }; use http::{ header::{HeaderValue, CONNECTION, CONTENT_LENGTH, HOST, TRANSFER_ENCODING}, request::Request, Method, Version, }; use log::trace; use super::{ config::ConnectorConfig, connection::{ConnectionIo, H2Connection}...
rust_dataset_chunk_1293
rust_dataset.txt
1,293
512
.unwrap_or_else(HeaderMap::new), ), }; // merging headers from head and extra headers. let headers = head .as_ref() .headers .iter() .filter(|(name, _)| !extra_headers.contains_key(*name)) .chain(extra_headers.iter()); // copy headers for (key, value...
rust_dataset_chunk_1294
rust_dataset.txt
1,294
512
::Body(err.into())), None => { if let Err(err) = send.send_data(Bytes::new(), true) { return Err(err.into()); } send.reserve_capacity(0); return Ok(()); } } } ...
rust_dataset_chunk_1295
rust_dataset.txt
1,295
512
/// and memory usage. /// /// # Examples /// ``` /// use awc::Client; /// /// #[actix_rt::main] /// async fn main() { /// let mut client = Client::default(); /// /// let res = client.get("http://www.rust-lang.org") /// .insert_header(("User-Agent", "my-app/1.2")) /// .send() /// .await;...
rust_dataset_chunk_1296
rust_dataset.txt
1,296
512
/// Construct HTTP *GET* request. pub fn get<U>(&self, url: U) -> ClientRequest where Uri: TryFrom<U>, <Uri as TryFrom<U>>::Error: Into<HttpError>, { self.request(Method::GET, url) } /// Construct HTTP *HEAD* request. pub fn head<U>(&self, url: U) -> ClientRequest w...
rust_dataset_chunk_1297
rust_dataset.txt
1,297
512
Error>, { self.request(Method::from_bytes(b"QUERY").unwrap(), url) } /// Initialize a WebSocket connection. /// Returns a WebSocket connection builder. pub fn ws<U>(&self, url: U) -> ws::WebsocketsRequest where Uri: TryFrom<U>, <Uri as TryFrom<U>>::Error: Into<HttpError>...
rust_dataset_chunk_1298
rust_dataset.txt
1,298
512
fn from(authority: Authority) -> Key { Key { authority } } } /// Connections pool to reuse I/O per [`Authority`]. #[doc(hidden)] pub struct ConnectionPool<S, Io> where Io: AsyncWrite + Unpin + 'static, { connector: S, inner: ConnectionPoolInner<Io>, } /// Wrapper type for check the ref count ...
rust_dataset_chunk_1299
rust_dataset.txt
1,299
512
.for_each(|(_, conns)| { conns.into_iter().for_each(|pooled| self.close(pooled.conn)) }); } } } pub struct ConnectionPoolInnerPriv<Io> where Io: AsyncWrite + Unpin + 'static, { config: ConnectorConfig, available: RefCell<HashMap<Key, VecDeque<PooledConnectio...