mirror of
				https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
				synced 2025-11-04 16:23:41 +08:00 
			
		
		
		
	update
This commit is contained in:
		@@ -2,12 +2,13 @@
 | 
				
			|||||||
//
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use std::error::Error;
 | 
					use std::error::Error;
 | 
				
			||||||
 | 
					use std::sync::atomic::{AtomicU32, Ordering};
 | 
				
			||||||
use std::collections::HashMap;
 | 
					use std::collections::HashMap;
 | 
				
			||||||
use futures_util::{StreamExt};
 | 
					use futures_util::{StreamExt};
 | 
				
			||||||
use reqwest::Client;
 | 
					use reqwest::Client;
 | 
				
			||||||
use reqwest::header::{HeaderName, HeaderMap};
 | 
					use reqwest::header::{HeaderName, HeaderMap};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static mut REQUEST_COUNTER: u32 = 0;
 | 
					static REQUEST_COUNTER: AtomicU32 = AtomicU32::new(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[derive(Debug, Clone, serde::Serialize)]
 | 
					#[derive(Debug, Clone, serde::Serialize)]
 | 
				
			||||||
pub struct StreamResponse {
 | 
					pub struct StreamResponse {
 | 
				
			||||||
@@ -38,12 +39,8 @@ pub async fn stream_fetch(
 | 
				
			|||||||
  body: Vec<u8>,
 | 
					  body: Vec<u8>,
 | 
				
			||||||
) -> Result<StreamResponse, String> {
 | 
					) -> Result<StreamResponse, String> {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let mut request_id = 0;
 | 
					 | 
				
			||||||
  let event_name = "stream-response";
 | 
					  let event_name = "stream-response";
 | 
				
			||||||
  unsafe {
 | 
					  let request_id = REQUEST_COUNTER.fetch_add(1, Ordering::SeqCst);
 | 
				
			||||||
    REQUEST_COUNTER += 1;
 | 
					 | 
				
			||||||
    request_id = REQUEST_COUNTER;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let mut _headers = HeaderMap::new();
 | 
					  let mut _headers = HeaderMap::new();
 | 
				
			||||||
  for (key, value) in &headers {
 | 
					  for (key, value) in &headers {
 | 
				
			||||||
@@ -72,6 +69,10 @@ pub async fn stream_fetch(
 | 
				
			|||||||
    // println!("body: {:?}", body);
 | 
					    // println!("body: {:?}", body);
 | 
				
			||||||
    request = request.body(body);
 | 
					    request = request.body(body);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // println!("client: {:?}", client);
 | 
				
			||||||
 | 
					  // println!("request: {:?}", request);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let response_future = request.send();
 | 
					  let response_future = request.send();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  let res = response_future.await;
 | 
					  let res = response_future.await;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user