1use serde::{Deserialize, Serialize};
2use std::fmt;
3
4pub use reqwest::{
5 header::{self, HeaderMap, HeaderName, HeaderValue},
6 IntoUrl, Method, StatusCode, Url,
7};
8
9#[derive(Default, Debug, Clone, Copy)]
10pub enum ContentEncoding {
11 #[default]
13 IDENTITY,
14 GZIP,
16 COMPRESS,
18 DEFLATE,
20 BR,
22}
23
24impl fmt::Display for ContentEncoding {
25 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26 write!(
27 f,
28 "{}",
29 match self {
30 Self::IDENTITY => "IDENTITY",
31 Self::GZIP => "GZIP",
32 Self::COMPRESS => "COMPRESS",
33 Self::DEFLATE => "DEFLATE",
34 Self::BR => "br",
35 }
36 )
37 }
38}
39
40#[derive(Default, Debug, Clone, Serialize, Deserialize)]
41pub enum ContentDisposition {
42 #[default]
43 INLINE,
44 ATTACHMENT(Option<String>),
45}
46
47impl fmt::Display for ContentDisposition {
48 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
49 write!(
50 f,
51 "{}",
52 match self {
53 Self::INLINE => "inline".to_owned(),
54 Self::ATTACHMENT(Some(filename)) => format!("attachment;filename=\"{}\"", filename),
55 Self::ATTACHMENT(None) => "attachment".to_owned(),
56 }
57 )
58 }
59}
60
61#[derive(Debug, Default, Clone, Copy)]
63pub enum CacheControl {
64 NoCache,
66 NoStore,
68 #[default]
70 PUBLIC,
71 PRIVATE,
73 MaxAge(u32),
75}
76
77impl fmt::Display for CacheControl {
78 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
79 write!(
80 f,
81 "{}",
82 match self {
83 CacheControl::NoCache => "no-cache".into(),
84 CacheControl::NoStore => "no-store".into(),
85 CacheControl::PUBLIC => "public".into(),
86 CacheControl::PRIVATE => "private".into(),
87 CacheControl::MaxAge(seconds) => format!("max-age=<{}>", seconds),
88 }
89 )
90 }
91}
92
93#[cfg(test)]
94mod tests {
95
96 #[test]
97 fn content_disposition_1() {
98 let filename: Option<String> = Some("测试.txt".to_string());
99 let value = crate::oss::http::ContentDisposition::ATTACHMENT(filename);
100 assert!(value.to_string().contains("测试"))
101 }
102}