mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2026-02-19 12:54:27 +08:00
Compare commits
2 Commits
d830c23dab
...
9c577ad9d5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c577ad9d5 | ||
|
|
953114041b |
@@ -320,9 +320,12 @@ export function adapter(config: Record<string, unknown>) {
|
||||
const fetchUrl = params
|
||||
? `${path}?${new URLSearchParams(params as any).toString()}`
|
||||
: path;
|
||||
return fetch(fetchUrl as string, { ...rest, responseType: "text" })
|
||||
.then((res) => res.text())
|
||||
.then((data) => ({ data }));
|
||||
return fetch(fetchUrl as string, { ...rest, responseType: "text" }).then(
|
||||
(res) => {
|
||||
const { status, headers } = res;
|
||||
return res.text().then((data) => ({ status, headers, data }));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export function safeLocalStorage(): {
|
||||
|
||||
@@ -222,7 +222,10 @@ export function stream(
|
||||
),
|
||||
)
|
||||
.then((res) => {
|
||||
const content = JSON.stringify(res.data);
|
||||
let content = res.data;
|
||||
try {
|
||||
content = JSON.stringify(res.data);
|
||||
} catch (e) {}
|
||||
if (res.status >= 300) {
|
||||
return Promise.reject(content);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//
|
||||
//
|
||||
|
||||
use std::time::Duration;
|
||||
use std::error::Error;
|
||||
use std::sync::atomic::{AtomicU32, Ordering};
|
||||
use std::collections::HashMap;
|
||||
@@ -56,6 +57,7 @@ pub async fn stream_fetch(
|
||||
let client = Client::builder()
|
||||
.default_headers(_headers)
|
||||
.redirect(reqwest::redirect::Policy::limited(3))
|
||||
.connect_timeout(Duration::new(3, 0))
|
||||
.build()
|
||||
.map_err(|err| format!("failed to generate client: {}", err))?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user