file_path
stringlengths
3
280
file_language
stringclasses
66 values
content
stringlengths
1
1.04M
repo_name
stringlengths
5
92
repo_stars
int64
0
154k
repo_description
stringlengths
0
402
repo_primary_language
stringclasses
108 values
developer_username
stringlengths
1
25
developer_name
stringlengths
0
30
developer_company
stringlengths
0
82
src/client/request.rs
Rust
use std::{ convert::TryFrom, fmt, future::Future, net::{IpAddr, Ipv4Addr, Ipv6Addr}, time::Duration, }; use http::{Extensions, Request as HttpRequest, Uri, Version}; #[cfg(any(feature = "query", feature = "form", feature = "json"))] use serde::Serialize; #[cfg(feature = "multipart")] use {super::mu...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/client/response.rs
Rust
use std::{ net::SocketAddr, pin::Pin, task::{Context, Poll}, }; use bytes::Bytes; #[cfg(feature = "charset")] use encoding_rs::{Encoding, UTF_8}; #[cfg(feature = "stream")] use futures_util::Stream; use http::{HeaderMap, StatusCode, Uri, Version}; use http_body::{Body as HttpBody, Frame}; use http_body_uti...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/client/ws.rs
Rust
//! WebSocket Upgrade #[cfg(feature = "json")] mod json; pub mod message; use std::{ borrow::Cow, fmt, net::{IpAddr, Ipv4Addr, Ipv6Addr}, ops::{Deref, DerefMut}, pin::Pin, task::{Context, Poll, ready}, }; use futures_util::{Sink, SinkExt, Stream, StreamExt, stream::FusedStream}; use http::{ ...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/client/ws/json.rs
Rust
use serde::{Serialize, de::DeserializeOwned}; use super::{Message, Utf8Bytes}; use crate::Error; impl Message { /// Tries to serialize the JSON as a [`Message::Text`]. /// /// # Optional /// /// This requires the optional `json` feature enabled. /// /// # Errors /// /// Serializati...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/client/ws/message.rs
Rust
//! WebSocket message types and utilities //! //! This module provides WebSocket message types that wrap the underlying //! tungstenite message implementation, offering a more ergonomic API //! for working with WebSocket communications. use std::{fmt, ops::Deref}; use bytes::Bytes; use super::tungstenite; use crate:...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/config.rs
Rust
//! The `config` module provides a generic mechanism for loading and managing //! request-scoped configuration. //! //! # Design Overview //! //! This module is centered around two abstractions: //! //! - The [`RequestConfigValue`] trait, used to associate a config key type with its value type. //! - The [`RequestConfi...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/cookie.rs
Rust
//! HTTP Cookies use std::{convert::TryInto, fmt, sync::Arc, time::SystemTime}; use bytes::Bytes; use cookie::{Cookie as RawCookie, CookieJar, Expiration, SameSite}; use http::Uri; use crate::{IntoUri, error::Error, ext::UriExt, hash::HashMap, header::HeaderValue, sync::RwLock}; /// Cookie header values in two form...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/dns.rs
Rust
//! DNS resolution pub(crate) mod gai; #[cfg(feature = "hickory-dns")] pub(crate) mod hickory; pub(crate) mod resolve; pub use resolve::{Addrs, IntoResolve, Name, Resolve, Resolving}; pub(crate) use self::{ gai::{GaiResolver, SocketAddrs}, resolve::{DnsResolverWithOverrides, DynResolver}, sealed::{Intern...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/dns/gai.rs
Rust
use std::{ future::Future, io, net::{Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6, ToSocketAddrs}, pin::Pin, task::{self, Poll}, vec, }; use tokio::task::JoinHandle; use tower::Service; use super::{Addrs, Name, Resolve, Resolving}; /// A resolver using blocking `getaddrinfo` cal...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/dns/hickory.rs
Rust
//! DNS resolution via the [hickory-resolver](https://github.com/hickory-dns/hickory-dns) crate use std::{net::SocketAddr, sync::LazyLock}; use hickory_resolver::{ TokioResolver, config::{LookupIpStrategy, ResolverConfig}, lookup_ip::LookupIpIntoIter, name_server::TokioConnectionProvider, }; use supe...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/dns/resolve.rs
Rust
use std::{ borrow::Cow, collections::HashMap, fmt, future::Future, net::SocketAddr, pin::Pin, sync::Arc, task::{Context, Poll}, }; use tower::Service; use crate::error::BoxError; /// A domain name to resolve into IP addresses. #[derive(Clone, Hash, Eq, PartialEq)] pub struct Name { ...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/error.rs
Rust
use std::{error::Error as StdError, fmt, io}; use http::Uri; use crate::{StatusCode, client::ext::ReasonPhrase, util::Escape}; /// A `Result` alias where the `Err` case is `wreq::Error`. pub type Result<T> = std::result::Result<T, Error>; /// A boxed error type that can be used for dynamic error handling. pub type ...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/ext.rs
Rust
//! Extension utilities. use bytes::Bytes; use http::uri::{Authority, Scheme, Uri}; use percent_encoding::{AsciiSet, CONTROLS}; use crate::Body; /// See: <https://url.spec.whatwg.org/#fragment-percent-encode-set> const FRAGMENT: &AsciiSet = &CONTROLS.add(b' ').add(b'"').add(b'<').add(b'>').add(b'`'); /// See: <http...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/hash.rs
Rust
use std::{ borrow::Borrow, hash::{BuildHasher, Hash, Hasher}, num::NonZeroU64, sync::atomic::{AtomicU64, Ordering}, }; use ahash::RandomState; #[derive(Debug, Clone, Copy, Default)] pub struct AHashlState; impl BuildHasher for AHashlState { type Hasher = <RandomState as BuildHasher>::Hasher; ...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/header.rs
Rust
//! HTTP header types //! //! This module provides [`HeaderName`], [`HeaderMap`], [`OrigHeaderMap`], [`OrigHeaderName`], and a //! number of types used for interacting with `HeaderMap`. These types allow representing both //! HTTP/1 and HTTP/2 headers. pub use http::header::*; pub use name::OrigHeaderName; /// Trait ...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/into_uri.rs
Rust
//! URI conversion utilities. //! //! This module provides the [`IntoUri`] trait, allowing various types //! (such as `&str`, `String`, `Vec<u8>`, etc.) to be fallibly converted into an [`http::Uri`]. //! The conversion is based on `TryFrom<T> for Uri` and ensures the resulting URI is valid and //! contains a host. //!...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/lib.rs
Rust
#![deny(unused)] #![deny(unsafe_code)] #![deny(missing_docs)] #![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(test, deny(warnings))] #![cfg_attr(not(test), warn(unused_crate_dependencies))] //! # wreq //! //! An ergonomic all-in-one HTTP client for browser emulation with TLS, JA3/JA4, and HTTP/2 //! fingerprints. /...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/proxy.rs
Rust
#[cfg(all(target_os = "macos", feature = "system-proxy"))] mod mac; #[cfg(unix)] mod uds; #[cfg(all(windows, feature = "system-proxy"))] mod win; pub(crate) mod matcher; use std::hash::{Hash, Hasher}; #[cfg(unix)] use std::{path::Path, sync::Arc}; use http::{HeaderMap, Uri, header::HeaderValue}; use crate::{IntoUri...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/proxy/mac.rs
Rust
use system_configuration::{ core_foundation::{ base::CFType, dictionary::CFDictionary, number::CFNumber, string::{CFString, CFStringRef}, }, dynamic_store::SCDynamicStoreBuilder, sys::schema_definitions::{ kSCPropNetProxiesHTTPEnable, kSCPropNetProxiesHTTPPort, kS...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/proxy/matcher.rs
Rust
//! Proxy matchers //! //! This module contains different matchers to configure rules for when a proxy //! should be used, and if so, with what arguments. //! //! A [`Matcher`] can be constructed either using environment variables, or //! a [`Matcher::builder()`]. //! //! Once constructed, the `Matcher` can be asked if...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/proxy/uds.rs
Rust
use std::{ path::{Path, PathBuf}, sync::Arc, }; /// Trait for converting various types into a shared Unix Domain Socket path (`Arc<Path>`). /// /// This trait is sealed to allow future extension while controlling which types can implement it. /// It enables ergonomic conversion from common path types such as `...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/proxy/win.rs
Rust
pub(super) fn with_system(builder: &mut super::matcher::Builder) { let Ok(settings) = windows_registry::CURRENT_USER .open("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings") else { return; }; if settings.get_u32("ProxyEnable").unwrap_or(0) == 0 { return; } ...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/redirect.rs
Rust
//! Redirect Handling //! //! By default, a `Client` does not follow HTTP redirects. To enable automatic //! redirect handling with a maximum redirect chain of 10 hops, use a [`Policy`] //! with [`ClientBuilder::redirect()`](crate::ClientBuilder::redirect). use std::{borrow::Cow, error::Error as StdError, fmt, sync::A...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/retry.rs
Rust
//! Retry requests //! //! A `Client` has the ability to retry requests, by sending additional copies //! to the server if a response is considered retryable. //! //! The [`Policy`] makes it easier to configure what requests to retry, along //! with including best practices by default, such as a retry budget. //! //! #...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/sync.rs
Rust
//! Synchronization primitives: [`Mutex`] and [`RwLock`] that never poison. //! //! These types expose APIs identical to [`std::sync::Mutex`] and [`std::sync::RwLock`], //! but **do not return** [`std::sync::PoisonError`] even if a thread panics while holding the lock. //! //! This is useful in high-availability system...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/tls.rs
Rust
//! TLS options configuration //! //! By default, a `Client` will make use of BoringSSL for TLS. //! //! - Various parts of TLS can also be configured or even disabled on the `ClientBuilder`. pub(crate) mod conn; mod keylog; mod options; mod x509; use boring2::ssl; pub use boring2::ssl::{CertificateCompressionAlgori...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/tls/conn.rs
Rust
//! SSL support via BoringSSL. #[macro_use] mod macros; mod cache; mod cert_compression; mod ext; mod service; use std::{ borrow::Cow, fmt::{self, Debug}, io, pin::Pin, sync::{Arc, LazyLock}, task::{Context, Poll}, }; use boring2::{ error::ErrorStack, ex_data::Index, ssl::{Ssl, Ss...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/tls/conn/cache.rs
Rust
use std::{ borrow::Borrow, collections::hash_map::Entry, hash::{Hash, Hasher}, num::NonZeroUsize, }; use crate::hash::{AHashlState, HashMap, LruMap}; use boring2::ssl::{SslSession, SslSessionRef, SslVersion}; /// A typed key for indexing TLS sessions in the cache. /// /// This wrapper provides type sa...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/tls/conn/cert_compression.rs
Rust
use std::io::{self, Read, Result, Write}; use boring2::ssl::{CertificateCompressionAlgorithm, CertificateCompressor}; use brotli::{CompressorWriter, Decompressor}; use flate2::{Compression, read::ZlibDecoder, write::ZlibEncoder}; use zstd::stream::{Decoder as ZstdDecoder, Encoder as ZstdEncoder}; #[derive(Debug, Clon...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/tls/conn/ext.rs
Rust
use boring2::ssl::{SslConnectorBuilder, SslVerifyMode}; use crate::{ Error, tls::{ CertificateCompressionAlgorithm, conn::cert_compression::{ BrotliCertificateCompressor, ZlibCertificateCompressor, ZstdCertificateCompressor, }, x509::CertStore, }, }; /// SslConn...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/tls/conn/macros.rs
Rust
macro_rules! set_bool { ($cfg:expr, $field:ident, $conn:expr, $setter:ident) => { if $cfg.$field { $conn.$setter(); } }; ($cfg:expr, !$field:ident, $conn:expr, $setter:ident, $arg:expr) => { if !$cfg.$field { $conn.$setter($arg); } }; } macro_rule...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/tls/conn/service.rs
Rust
use std::{ fmt::Debug, future::Future, pin::Pin, task::{Context, Poll}, }; use http::{Uri, uri::Scheme}; use tokio::io::{AsyncRead, AsyncWrite}; use tokio_boring2::SslStream; use tower::Service; use super::{EstablishedConn, HttpsConnector, MaybeHttpsStream}; use crate::{ client::{ConnectRequest, C...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/tls/keylog.rs
Rust
//! TLS Key Log Management //! //! This module provides utilities for managing TLS key logging, allowing session keys to be //! written to a file for debugging or analysis (e.g., with Wireshark). //! //! The [`KeyLog`] enum lets you control key log behavior, either by respecting the //! `SSLKEYLOGFILE` environment vari...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/tls/keylog/handle.rs
Rust
use std::{ fs::OpenOptions, io::{Result, Write}, path::Path, sync::{ Arc, mpsc::{self, Sender}, }, }; /// Handle for writing to a key log file. #[derive(Debug, Clone)] pub struct Handle { #[allow(unused)] filepath: Arc<Path>, sender: Sender<String>, } impl Handle { ...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/tls/options.rs
Rust
use std::borrow::Cow; use super::{ AlpnProtocol, AlpsProtocol, CertificateCompressionAlgorithm, ExtensionType, TlsVersion, }; /// Builder for `[`TlsOptions`]`. #[must_use] #[derive(Debug, Clone)] pub struct TlsOptionsBuilder { config: TlsOptions, } /// TLS connection configuration options. /// /// This struc...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/tls/x509.rs
Rust
mod identity; mod parser; mod store; use boring2::x509::X509; pub use self::{ identity::Identity, store::{CertStore, CertStoreBuilder}, }; use crate::Error; /// A certificate input. pub enum CertificateInput<'c> { /// Raw DER or PEM data. Raw(&'c [u8]), /// An already parsed certificate. Pars...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/tls/x509/identity.rs
Rust
use boring2::{ pkcs12::Pkcs12, pkey::{PKey, Private}, x509::X509, }; use crate::Error; /// Represents a private key and X509 cert as a client certificate. #[derive(Debug, Clone)] pub struct Identity { pkey: PKey<Private>, cert: X509, chain: Vec<X509>, } impl Identity { /// Parses a DER-fo...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/tls/x509/parser.rs
Rust
use boring2::x509::store::{X509Store, X509StoreBuilder}; use super::{Certificate, CertificateInput}; use crate::{Error, Result}; pub fn parse_certs<'c, I>( certs: I, parser: fn(&'c [u8]) -> crate::Result<Certificate>, ) -> Result<X509Store> where I: IntoIterator, I::Item: Into<CertificateInput<'c>>, {...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/tls/x509/store.rs
Rust
use std::sync::Arc; use boring2::{ ssl::SslConnectorBuilder, x509::store::{X509Store, X509StoreBuilder}, }; use super::{ Certificate, CertificateInput, parser::{filter_map_certs, parse_certs, parse_certs_with_stack, process_certs}, }; use crate::{Error, Result}; /// A builder for constructing a `Cert...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/trace.rs
Rust
macro_rules! debug { ($($arg:tt)+) => { { #[cfg(feature = "tracing")] { ::tracing::debug!($($arg)+); } } } } macro_rules! trace { ($($arg:tt)*) => { { #[cfg(feature = "tracing")] { ::tracing:...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
src/util.rs
Rust
use std::{fmt, fmt::Write}; use bytes::Bytes; use crate::header::{Entry, HeaderMap, HeaderValue, OccupiedEntry}; pub(crate) fn basic_auth<U, P>(username: U, password: Option<P>) -> HeaderValue where U: fmt::Display, P: fmt::Display, { let encoded = { let mut buf = b"Basic ".to_vec(); let ...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/badssl.rs
Rust
use std::time::Duration; use wreq::{ Client, tls::{AlpsProtocol, CertStore, TlsInfo, TlsOptions, TlsVersion}, }; macro_rules! join { ($sep:expr, $first:expr $(, $rest:expr)*) => { concat!($first $(, $sep, $rest)*) }; } #[tokio::test] async fn test_badssl_modern() { let text = Client::buil...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/brotli.rs
Rust
mod support; use std::io::Read; use support::server; use tokio::io::AsyncWriteExt; use wreq::Client; #[tokio::test] async fn brotli_response() { brotli_case(10_000, 4096).await; } #[tokio::test] async fn brotli_single_byte_chunks() { brotli_case(10, 1).await; } #[tokio::test] async fn test_brotli_empty_body...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/client.rs
Rust
mod support; #[cfg(feature = "json")] use std::collections::HashMap; use bytes::Bytes; use http::{ HeaderMap, HeaderValue, StatusCode, Version, header::{ self, ACCEPT, AUTHORIZATION, CACHE_CONTROL, CONTENT_LENGTH, CONTENT_TYPE, COOKIE, REFERER, TRANSFER_ENCODING, USER_AGENT, }, }; use http...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/connector_layers.rs
Rust
mod support; use std::time::Duration; use futures_util::future::join_all; use pretty_env_logger::env_logger; use support::{layer::DelayLayer, server}; use tower::{layer::util::Identity, limit::ConcurrencyLimitLayer, timeout::TimeoutLayer}; use wreq::Client; #[tokio::test] async fn non_op_layer() { let _ = env_lo...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/cookie.rs
Rust
mod support; use std::sync::Arc; use http::header::COOKIE; use support::server; use wreq::{Client, cookie::Jar}; #[tokio::test] async fn cookie_response_accessor() { let server = server::http(move |_req| async move { http::Response::builder() .header("Set-Cookie", "key=val") .heade...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/deflate.rs
Rust
mod support; use std::io::Write; use flate2::{Compression, write::ZlibEncoder}; use support::server; use tokio::io::AsyncWriteExt; #[tokio::test] async fn deflate_response() { deflate_case(10_000, 4096).await; } #[tokio::test] async fn deflate_single_byte_chunks() { deflate_case(10, 1).await; } #[tokio::tes...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/emulation.rs
Rust
use std::time::Duration; use wreq::{ Client, Emulation, http1::Http1Options, http2::{ Http2Options, PseudoId, PseudoOrder, SettingId, SettingsOrder, StreamDependency, StreamId, }, tls::{AlpnProtocol, CertificateCompressionAlgorithm, ExtensionType, TlsOptions, TlsVersion}, }; macro_rules! j...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/gzip.rs
Rust
mod support; use std::io::Write; use flate2::{Compression, write::GzEncoder}; use support::server; use tokio::io::AsyncWriteExt; #[tokio::test] async fn gzip_response() { gzip_case(10_000, 4096).await; } #[tokio::test] async fn gzip_single_byte_chunks() { gzip_case(10, 1).await; } #[tokio::test] async fn te...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/layers.rs
Rust
mod support; use std::time::Duration; use futures_util::future::join_all; use pretty_env_logger::env_logger; use support::{ layer::{DelayLayer, SharedConcurrencyLimitLayer}, server, }; use tower::{layer::util::Identity, limit::ConcurrencyLimitLayer, timeout::TimeoutLayer}; use wreq::Client; #[tokio::test] as...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/multipart.rs
Rust
mod support; use http_body_util::BodyExt; use pretty_env_logger::env_logger; use support::server; #[tokio::test] async fn text_part() { let _ = env_logger::try_init(); let form = wreq::multipart::Form::new().text("foo", "bar"); let expected_body = format!( "\ --{0}\r\n\ Content-...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/proxy.rs
Rust
mod support; use std::{env, sync::LazyLock}; use support::server; use tokio::sync::Mutex; use wreq::Client; // serialize tests that read from / write to environment variables static HTTP_PROXY_ENV_MUTEX: LazyLock<Mutex<()>> = LazyLock::new(|| Mutex::new(())); #[tokio::test] async fn http_proxy() { let url = "htt...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/redirect.rs
Rust
mod support; use http::StatusCode; use http_body_util::BodyExt; use support::server; use wreq::{ Body, Client, redirect::{History, Policy}, }; #[tokio::test] async fn test_redirect_301_and_302_and_303_changes_post_to_get() { let codes = [301u16, 302, 303]; for &code in &codes { let redirect = ...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/retry.rs
Rust
mod support; use std::sync::{ Arc, atomic::{AtomicUsize, Ordering}, }; use support::server; use wreq::Client; #[tokio::test] async fn retries_apply_in_scope() { let _ = pretty_env_logger::try_init(); let cnt = Arc::new(AtomicUsize::new(0)); let server = server::http(move |_req| { let cnt...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/support/delay_server.rs
Rust
#![allow(unused)] use std::{convert::Infallible, future::Future, net, time::Duration}; use futures_util::FutureExt; use http::{Request, Response}; use hyper::service::service_fn; use tokio::{net::TcpListener, select, sync::oneshot}; /// This server, unlike [`super::server::Server`], allows for delaying the /// specif...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/support/error.rs
Rust
use std::error::Error as StdError; #[allow(unused)] pub fn inspect<E>(err: E) -> Vec<String> where E: Into<Box<dyn StdError + Send + Sync>>, { let berr = err.into(); let mut err = Some(&*berr as &(dyn StdError + 'static)); let mut errs = Vec::new(); while let Some(e) = err { errs.push(e.to_...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/support/layer.rs
Rust
use std::{ future::Future, pin::Pin, task::{Context, Poll}, time::Duration, }; use futures::future::BoxFuture; use pin_project_lite::pin_project; use tokio::time::Sleep; use tower::{BoxError, Layer, Service}; /// This tower layer injects an arbitrary delay before calling downstream layers. #[derive(Cl...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/support/mod.rs
Rust
pub mod delay_server; pub mod error; pub mod layer; pub mod server; // TODO: remove once done converting to new support server? #[allow(unused)] pub static DEFAULT_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"));
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/support/server.rs
Rust
use std::{ convert::Infallible, future::Future, io, net, sync::mpsc as std_mpsc, thread, time::Duration, }; use tokio::{io::AsyncReadExt, net::TcpStream, runtime, sync::oneshot}; use wreq::Body; pub struct Server { addr: net::SocketAddr, panic_rx: std_mpsc::Receiver<()>, events_rx: std_mpsc::Receiver<...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/timeouts.rs
Rust
mod support; use std::time::Duration; use pretty_env_logger::env_logger; use support::server; use wreq::Client; #[tokio::test] async fn client_timeout() { let _ = env_logger::try_init(); let server = server::http(move |_req| { async { // delay returning the response tokio::tim...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/unix_socket.rs
Rust
#![cfg(unix)] use std::{hash::BuildHasher, time::Duration}; use http::Method; use http_body_util::Full; use hyper::{Request, Response, body::Incoming, service::service_fn}; use hyper_util::{ rt::{TokioExecutor, TokioIo}, server::conn::auto::Builder, }; use tokio::{net::UnixListener, task}; use wreq::{Client, ...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/upgrade.rs
Rust
mod support; use http::Method; use support::server; use tokio::io::{AsyncReadExt, AsyncWriteExt}; use wreq::Client; #[tokio::test] async fn http_upgrade() { let server = server::http(move |req| { assert_eq!(req.method(), "GET"); assert_eq!(req.headers()["connection"], "upgrade"); assert_eq!...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
tests/zstd.rs
Rust
mod support; use support::server; use tokio::io::AsyncWriteExt; use wreq::Client; #[tokio::test] async fn zstd_response() { zstd_case(10_000, 4096).await; } #[tokio::test] async fn zstd_single_byte_chunks() { zstd_case(10, 1).await; } #[tokio::test] async fn test_zstd_empty_body() { let server = server::...
0x676e67/wreq
630
An ergonomic Rust HTTP Client with TLS fingerprint
Rust
0x676e67
examples/emulation.rs
Rust
use wreq::Client; use wreq_util::{Emulation, EmulationOS, EmulationOption}; #[tokio::main] async fn main() -> Result<(), wreq::Error> { // Example 1: Basic emulation - Safari26 println!("=== Example 1: Basic Safari26 Emulation ==="); let client1 = Client::builder() .emulation(Emulation::Safari26) ...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
examples/tower_delay.rs
Rust
use std::time::{Duration, Instant}; use wreq::Client; use wreq_util::tower::delay::DelayLayer; #[tokio::main] async fn main() -> Result<(), wreq::Error> { // Build a client with a 1 second delay between requests let client = Client::builder() .layer(DelayLayer::new(Duration::from_secs(1))) .ce...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
examples/tower_jitter_delay.rs
Rust
use std::time::{Duration, Instant}; use wreq::Client; use wreq_util::tower::delay::{DelayLayer, JitterDelayLayer}; #[tokio::main] async fn main() -> Result<(), wreq::Error> { // Example 1: Basic jittered delay for all requests basic_jitter_delay().await?; println!("\n{}\n", "=".repeat(60)); // Examp...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/emulation.rs
Rust
mod device; #[cfg(feature = "emulation-rand")] mod rand; use device::{chrome::*, firefox::*, okhttp::*, opera::*, safari::*}; #[cfg(feature = "emulation-serde")] use serde::{Deserialize, Serialize}; #[cfg(feature = "emulation-rand")] use strum_macros::VariantArray; use typed_builder::TypedBuilder; macro_rules! define...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/emulation/device.rs
Rust
//! Emulation for different browsers. #[macro_use] mod macros; pub mod chrome; pub mod firefox; pub mod okhttp; pub mod opera; pub mod safari; pub use typed_builder::TypedBuilder; #[cfg(feature = "emulation-compression")] pub use wreq::header::ACCEPT_ENCODING; pub use wreq::{ Emulation, header::{ACCEPT, ACCEP...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/emulation/device/chrome.rs
Rust
#[macro_use] mod http2; #[macro_use] mod tls; mod header; use header::*; use tls::*; use super::*; mod_generator!( v100, tls_options!(1), http2_options!(1), header_initializer, [ ( MacOS, r#""Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100""#, ...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/emulation/device/chrome/header.rs
Rust
use super::*; pub fn header_initializer( sec_ch_ua: &'static str, ua: &'static str, emulation_os: EmulationOS, ) -> HeaderMap { let mut headers = HeaderMap::new(); header_chrome_sec_ch_ua!( headers, sec_ch_ua, emulation_os.platform(), emulation_os.is_mobile() ); ...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/emulation/device/chrome/http2.rs
Rust
macro_rules! headers_stream_dependency { () => { StreamDependency::new(StreamId::zero(), 219, true) }; } macro_rules! pseudo_order { () => { PseudoOrder::builder() .extend([ PseudoId::Method, PseudoId::Authority, PseudoId::Scheme, ...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/emulation/device/chrome/tls.rs
Rust
use super::*; macro_rules! tls_options { (@build $builder:expr) => { $builder.build().into() }; (1) => { tls_options!(@build ChromeTlsConfig::builder()) }; (2) => { tls_options!(@build ChromeTlsConfig::builder().enable_ech_grease(true)) }; (3) => { tls_optio...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/emulation/device/firefox.rs
Rust
#[macro_use] mod http2; #[macro_use] mod tls; mod header; use header::*; use tls::*; use super::*; macro_rules! mod_generator { ( $mod_name:ident, $tls_options:expr, $http2_options:expr, $header_initializer:ident, [($default_os:ident, $default_ua:tt) $(, ($other_os:ident, ...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/emulation/device/firefox/header.rs
Rust
use super::*; pub fn header_initializer(ua: &'static str) -> HeaderMap { let mut headers = HeaderMap::new(); header_firefox_ua!(headers, ua); header_firefox_accept!(headers); header_firefox_sec_fetch!(headers); headers } pub fn header_initializer_with_zstd(ua: &'static str) -> HeaderMap { let ...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/emulation/device/firefox/http2.rs
Rust
macro_rules! headers_stream_dependency { (1) => { StreamDependency::new(StreamId::zero(), 21, false) }; (2) => { StreamDependency::new(StreamId::from(13), 21, false) }; } macro_rules! pseudo_order { () => { PseudoOrder::builder() .extend([ PseudoI...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/emulation/device/firefox/tls.rs
Rust
use super::*; macro_rules! tls_options { (@build $builder:expr) => { $builder.build().into() }; (@base $builder:expr, $cipher_list:expr, $curves:expr) => { $builder .cipher_list($cipher_list) .curves_list($curves) }; (1, $cipher_list:expr, $curves:expr) => ...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/emulation/device/macros.rs
Rust
macro_rules! header_chrome_sec_ch_ua { ($headers:expr, $ua:expr, $platform:expr, $is_mobile:expr) => { let mobile = if $is_mobile { "?1" } else { "?0" }; $headers.insert("sec-ch-ua", HeaderValue::from_static($ua)); $headers.insert("sec-ch-ua-mobile", HeaderValue::from_static(mobile)); ...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/emulation/device/okhttp.rs
Rust
use super::*; macro_rules! mod_generator { ($mod_name:ident, $cipher:expr, $ua:expr) => { pub(crate) mod $mod_name { use super::*; pub fn emulation(option: EmulationOption) -> Emulation { build_emulation(option, $cipher, $ua) } } }; } const C...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/emulation/device/opera.rs
Rust
#[macro_use] mod http2; #[macro_use] mod tls; mod header; use header::*; use tls::*; use super::*; mod_generator!( opera116, tls_options!(CURVES), http2_options!(), header_initializer_with_zstd_priority, [ ( MacOS, r#""Opera";v="116", "Chromium";v="131", "Not_A Bra...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/emulation/device/opera/header.rs
Rust
use super::*; #[inline] pub fn header_initializer_with_zstd_priority( sec_ch_ua: &'static str, ua: &'static str, emulation_os: EmulationOS, ) -> HeaderMap { let mut headers = HeaderMap::new(); header_chrome_sec_ch_ua!( headers, sec_ch_ua, emulation_os.platform(), emu...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/emulation/device/opera/http2.rs
Rust
macro_rules! headers_stream_dependency { () => { StreamDependency::new(StreamId::zero(), 219, true) }; } macro_rules! pseudo_order { () => { PseudoOrder::builder() .extend([ PseudoId::Method, PseudoId::Authority, PseudoId::Scheme, ...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/emulation/device/opera/tls.rs
Rust
use super::*; macro_rules! tls_options { ($curves:expr) => { OperaTlsConfig::builder() .curves($curves) .permute_extensions(true) .pre_shared_key(true) .enable_ech_grease(true) .build() .into() }; } pub const CURVES: &str = join!(...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/emulation/device/safari.rs
Rust
#[macro_use] mod http2; #[macro_use] mod tls; mod header; use header::*; use tls::*; use super::*; macro_rules! mod_generator { ($mod_name:ident, $tls_options:expr, $http2_options:expr, $header_initializer:ident, $ua:expr) => { pub(crate) mod $mod_name { use super::*; pub fn emul...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/emulation/device/safari/header.rs
Rust
use super::*; #[inline] pub fn header_initializer_for_15(ua: &'static str) -> HeaderMap { let mut headers = HeaderMap::new(); headers.insert(USER_AGENT, HeaderValue::from_static(ua)); headers.insert( ACCEPT, HeaderValue::from_static("text/html,application/xhtml+xml,application/xml;q=0.9,*/*...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/emulation/device/safari/http2.rs
Rust
macro_rules! headers_pseudo_order { (1) => { PseudoOrder::builder() .extend([ PseudoId::Method, PseudoId::Scheme, PseudoId::Path, PseudoId::Authority, ]) .build() }; (2) => { PseudoOrder::buil...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/emulation/device/safari/tls.rs
Rust
use super::*; macro_rules! tls_options { (1, $cipher_list:expr) => { SafariTlsConfig::builder() .cipher_list($cipher_list) .build() .into() }; (2, $cipher_list:expr, $sigalgs_list:expr) => { SafariTlsConfig::builder() .cipher_list($cipher_list...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/emulation/rand.rs
Rust
use std::{ cell::Cell, collections::hash_map::RandomState, hash::{BuildHasher, Hasher}, num::Wrapping, }; use strum::VariantArray; use super::{Emulation, EmulationOS, EmulationOption}; // from: https://github.com/seanmonstar/reqwest/blob/44ac897f1ab35ba24a195927043d185d5cbb6912/src/util.rs#L27 fn fas...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/lib.rs
Rust
#![deny(unused)] #![deny(unsafe_code)] #![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(test, deny(warnings))] #![cfg_attr(not(test), warn(unused_crate_dependencies))] #![doc = include_str!("../README.md")] #[cfg(feature = "emulation")] pub mod emulation; pub mod tower; #[cfg(feature = "emulation")] pub use self::e...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/tower.rs
Rust
//! Tower middleware helpers for `wreq`. //! //! Modules here are feature-gated. Enable the feature to make the tower middleware //! available and to include its docs. #[cfg(feature = "tower-delay")] pub mod delay;
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/tower/delay.rs
Rust
//! Request delay middleware. //! //! Adds configurable delays before HTTP requests — useful for rate limiting, //! testing under slow network conditions, or just being polite to APIs. //! //! # Quick Start //! //! Fixed 1-second delay: //! //! ```no_run //! use std::time::Duration; //! use wreq::Client; //! use wreq_u...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/tower/delay/future.rs
Rust
use std::{ pin::Pin, task::{Context, Poll, ready}, }; use pin_project_lite::pin_project; use tokio::time::Sleep; use tower::BoxError; pin_project! { /// Response future for [`Delay`]. /// /// [`Delay`]: super::Delay #[derive(Debug)] pub struct ResponseFuture<S> { #[pin] res...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/tower/delay/layer.rs
Rust
use std::time::Duration; use tower::Layer; use super::service::{Delay, DelayWith, JitterDelay, JitterDelayWith}; /// A Tower [`Layer`] that introduces a fixed delay before each request. #[derive(Clone, Debug)] pub struct DelayLayer { delay: Duration, } /// Conditional delay [`Layer`], applies delay based on a p...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
src/tower/delay/service.rs
Rust
use std::{ task::{Context, Poll}, time::Duration, }; use tower::{BoxError, Service}; use super::{future::ResponseFuture, jittered_duration}; /// A Tower [`Service`] that introduces a fixed delay before each request. #[derive(Debug, Clone)] pub struct Delay<S> { inner: S, delay: Duration, } /// A Tow...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
tests/client.rs
Rust
#![cfg(not(target_arch = "wasm32"))] mod support; use support::server; use wreq::Client; use wreq_util::{Emulation, EmulationOS, EmulationOption}; #[tokio::test] async fn test_client_emulation_device() { let server = server::http(move |req| async move { for (name, value) in req.headers() { if ...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
tests/emulation_chrome.rs
Rust
#[macro_use] mod support; use wreq_util::Emulation; // Enabling certain extensions will change the length during encryption. This is because TLS will // automatically use padding to fill the data and add a padding extension. At this time, the ja4 // fingerprint will change. test_emulation!( test_chrome100, E...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
tests/emulation_firefox.rs
Rust
#[macro_use] mod support; use wreq_util::Emulation; test_emulation!( test_firefox_109, Emulation::Firefox109, ["t13d1715h2_5b57614c22b0_3d5424432f57"], "73d042072ceabaedacfd45e84dff1020" ); test_emulation!( test_firefox_117, Emulation::Firefox117, ["t13d1715h2_5b57614c22b0_3d5424432f57"],...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
tests/emulation_okhttp.rs
Rust
#[macro_use] mod support; use wreq_util::Emulation; test_emulation!( test_okhttp3_13, Emulation::OkHttp3_13, ["t13d1613h2_46e7e9700bed_eca864cca44a"], "460a10a98dcc79ed1bf9ab07653d4f79" ); test_emulation!( test_okhttp3_14, Emulation::OkHttp3_14, ["t13d1613h2_46e7e9700bed_eca864cca44a"], ...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
tests/emulation_opera.rs
Rust
#[macro_use] mod support; use wreq_util::Emulation; // Enabling certain extensions will change the length during encryption. This is because TLS will // automatically use padding to fill the data and add a padding extension. At this time, the ja4 // fingerprint will change. test_emulation!( test_opera116, Em...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
tests/emulation_safari.rs
Rust
#[macro_use] mod support; use wreq_util::Emulation; test_emulation!( test_safari_15_3, Emulation::Safari15_3, ["t13d2614h2_2802a3db6c62_14788d8d241b"], "dda308d35f4e5db7b52a61720ca1b122" ); test_emulation!( test_safari_15_5, Emulation::Safari15_5, ["t13d2614h2_2802a3db6c62_14788d8d241b"],...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67
tests/support/delay_layer.rs
Rust
use std::{ future::Future, pin::Pin, task::{Context, Poll}, time::Duration, }; use pin_project_lite::pin_project; use tokio::time::Sleep; use tower::{BoxError, Layer, Service}; /// This tower layer injects an arbitrary delay before calling downstream layers. #[derive(Clone)] pub struct DelayLayer { ...
0x676e67/wreq-util
59
Common utilities for wreq
Rust
0x676e67