HTTP compression (Reddit -> Libreddit -> client) (#612)
Implements HTTP compression, between both Reddit and Libreddit and Libreddit and a web browser. Compression between Reddit and Libreddit is mandatory, whereas compression between Libreddit and a client is opt-in (client must specify a compressor in the Accept-Encoding header). Supported compressors are gzip and brotli. gzip support is ubiquitous, whereas brotli is supported by almost all modern browsers except Safari (iOS, iPhone, macOS), although Safari may support brotli in the future. Co-authored-by: Matthew E <matt@matthew.science>
This commit is contained in:
15
src/utils.rs
15
src/utils.rs
@ -13,6 +13,21 @@ use std::str::FromStr;
|
||||
use time::{macros::format_description, Duration, OffsetDateTime};
|
||||
use url::Url;
|
||||
|
||||
/// Write a message to stderr on debug mode. This function is a no-op on
|
||||
/// release code.
|
||||
#[macro_export]
|
||||
macro_rules! dbg_msg {
|
||||
($x:expr) => {
|
||||
#[cfg(debug_assertions)]
|
||||
eprintln!("{}:{}: {}", file!(), line!(), $x.to_string())
|
||||
};
|
||||
|
||||
($($x:expr),+) => {
|
||||
#[cfg(debug_assertions)]
|
||||
dbg_msg!(format!($($x),+))
|
||||
};
|
||||
}
|
||||
|
||||
// Post flair with content, background color and foreground color
|
||||
pub struct Flair {
|
||||
pub flair_parts: Vec<FlairPart>,
|
||||
|
Reference in New Issue
Block a user