#![deny(missing_debug_implementations)]
#![deny(missing_docs)]
#![allow(clippy::needless_doctest_main)]
#[cfg(feature = "tls-rustls")]
extern crate rustls_opt_dep as rustls;
macro_rules! debug {
($($arg:tt)+) => { log::debug!(target: "attohttpc", $($arg)+) };
}
macro_rules! warn {
($($arg:tt)+) => { log::warn!(target: "attohttpc", $($arg)+) };
}
#[cfg(feature = "charsets")]
pub mod charsets;
mod error;
mod happy;
#[cfg(feature = "multipart")]
mod multipart;
mod parsing;
mod request;
mod streams;
mod tls;
pub use crate::error::{Error, ErrorKind, InvalidResponseKind, Result};
#[cfg(feature = "multipart")]
pub use crate::multipart::{Multipart, MultipartBuilder, MultipartFile};
pub use crate::parsing::{Response, ResponseReader};
pub use crate::request::proxy::{ProxySettings, ProxySettingsBuilder};
pub use crate::request::{body, PreparedRequest, RequestBuilder, RequestInspector, Session};
#[cfg(feature = "charsets")]
pub use crate::{charsets::Charset, parsing::TextReader};
pub use http::Method;
pub use http::StatusCode;
pub mod header {
pub use http::header::*;
}
pub fn get<U>(base_url: U) -> RequestBuilder
where
U: AsRef<str>,
{
RequestBuilder::new(Method::GET, base_url)
}
pub fn post<U>(base_url: U) -> RequestBuilder
where
U: AsRef<str>,
{
RequestBuilder::new(Method::POST, base_url)
}
pub fn put<U>(base_url: U) -> RequestBuilder
where
U: AsRef<str>,
{
RequestBuilder::new(Method::PUT, base_url)
}
pub fn delete<U>(base_url: U) -> RequestBuilder
where
U: AsRef<str>,
{
RequestBuilder::new(Method::DELETE, base_url)
}
pub fn head<U>(base_url: U) -> RequestBuilder
where
U: AsRef<str>,
{
RequestBuilder::new(Method::HEAD, base_url)
}
pub fn options<U>(base_url: U) -> RequestBuilder
where
U: AsRef<str>,
{
RequestBuilder::new(Method::OPTIONS, base_url)
}
pub fn patch<U>(base_url: U) -> RequestBuilder
where
U: AsRef<str>,
{
RequestBuilder::new(Method::PATCH, base_url)
}
pub fn trace<U>(base_url: U) -> RequestBuilder
where
U: AsRef<str>,
{
RequestBuilder::new(Method::TRACE, base_url)
}
mod skip_debug {
use std::fmt;
#[derive(Clone)]
pub struct SkipDebug<T>(pub T);
impl<T> fmt::Debug for SkipDebug<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "...")
}
}
impl<T> From<T> for SkipDebug<T> {
fn from(val: T) -> SkipDebug<T> {
SkipDebug(val)
}
}
}