mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-01 10:01:07 +02:00
committed by
GitHub
parent
0a857f8fdc
commit
b7a2345b06
5
.changes/api-raw-headers.md
Normal file
5
.changes/api-raw-headers.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"api": patch
|
||||
---
|
||||
|
||||
Added `rawHeaders` to `http > Response`.
|
||||
5
.changes/raw-headers.md
Normal file
5
.changes/raw-headers.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"tauri": patch
|
||||
---
|
||||
|
||||
Add `raw_headers` to `tauri::api::http::ResponseData`.
|
||||
File diff suppressed because one or more lines are too long
@@ -351,11 +351,22 @@ impl Response {
|
||||
let url = self.2;
|
||||
|
||||
let mut headers = HashMap::new();
|
||||
let mut raw_headers = HashMap::new();
|
||||
for (name, value) in self.1.headers() {
|
||||
headers.insert(
|
||||
name.as_str().to_string(),
|
||||
String::from_utf8(value.as_bytes().to_vec())?,
|
||||
);
|
||||
raw_headers.insert(
|
||||
name.as_str().to_string(),
|
||||
self
|
||||
.1
|
||||
.headers()
|
||||
.get_all(name)
|
||||
.into_iter()
|
||||
.map(|v| String::from_utf8(v.as_bytes().to_vec()).map_err(Into::into))
|
||||
.collect::<crate::api::Result<Vec<String>>>()?,
|
||||
);
|
||||
}
|
||||
let status = self.1.status().as_u16();
|
||||
|
||||
@@ -377,6 +388,7 @@ impl Response {
|
||||
url,
|
||||
status,
|
||||
headers,
|
||||
raw_headers,
|
||||
data,
|
||||
})
|
||||
}
|
||||
@@ -403,6 +415,8 @@ pub struct ResponseData {
|
||||
pub status: u16,
|
||||
/// Response headers.
|
||||
pub headers: HashMap<String, String>,
|
||||
/// Response raw headers.
|
||||
pub raw_headers: HashMap<String, Vec<String>>,
|
||||
/// Response data.
|
||||
pub data: Value,
|
||||
}
|
||||
|
||||
@@ -128,6 +128,7 @@ interface IResponse<T> {
|
||||
url: string
|
||||
status: number
|
||||
headers: Record<string, string>
|
||||
rawHeaders: Record<string, string[]>
|
||||
data: T
|
||||
}
|
||||
|
||||
@@ -141,6 +142,8 @@ class Response<T> {
|
||||
ok: boolean
|
||||
/** The response headers. */
|
||||
headers: Record<string, string>
|
||||
/** The response raw headers. */
|
||||
rawHeaders: Record<string, string[]>
|
||||
/** The response data. */
|
||||
data: T
|
||||
|
||||
@@ -150,6 +153,7 @@ class Response<T> {
|
||||
this.status = response.status
|
||||
this.ok = this.status >= 200 && this.status < 300
|
||||
this.headers = response.headers
|
||||
this.rawHeaders = response.rawHeaders
|
||||
this.data = response.data
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user