mirror of
https://github.com/openai/codex.git
synced 2026-10-21 17:48:44 +00:00
[codex-http-state] keep per-surface store protocol agnostic [ci changed_files]
This commit is contained in:
@@ -10,18 +10,6 @@ pub fn is_allowed_chatgpt_host(host: &str) -> bool {
|
||||
.any(|suffix| host.ends_with(suffix))
|
||||
}
|
||||
|
||||
/// Returns whether `url` is an HTTPS or secure WebSocket ChatGPT URL that Codex
|
||||
/// may treat as first-party traffic.
|
||||
pub fn is_allowed_chatgpt_request_url(url: &str) -> bool {
|
||||
let Ok(url) = reqwest::Url::parse(url) else {
|
||||
return false;
|
||||
};
|
||||
if !matches!(url.scheme(), "https" | "wss") {
|
||||
return false;
|
||||
}
|
||||
url.host_str().is_some_and(is_allowed_chatgpt_host)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -48,25 +36,4 @@ mod tests {
|
||||
assert!(!is_allowed_chatgpt_host(host));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recognizes_secure_chatgpt_request_urls() {
|
||||
for url in [
|
||||
"https://chatgpt.com/backend-api/codex/responses",
|
||||
"https://preview.chatgpt.com/backend-api/codex/models",
|
||||
"wss://chatgpt-staging.com/backend-api/codex/responses",
|
||||
] {
|
||||
assert!(is_allowed_chatgpt_request_url(url));
|
||||
}
|
||||
|
||||
for url in [
|
||||
"http://chatgpt.com/backend-api/codex/responses",
|
||||
"ws://chatgpt.com/backend-api/codex/responses",
|
||||
"https://api.openai.com/v1/responses",
|
||||
"https://chatgpt.com.evil.example/backend-api",
|
||||
"not a url",
|
||||
] {
|
||||
assert!(!is_allowed_chatgpt_request_url(url));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ mod transport;
|
||||
|
||||
pub use crate::chatgpt_cloudflare_cookies::with_chatgpt_cloudflare_cookie_store;
|
||||
pub use crate::chatgpt_hosts::is_allowed_chatgpt_host;
|
||||
pub use crate::chatgpt_hosts::is_allowed_chatgpt_request_url;
|
||||
pub use crate::custom_ca::BuildCustomCaTransportError;
|
||||
/// Test-only subprocess hook for custom CA coverage.
|
||||
///
|
||||
@@ -26,8 +25,6 @@ pub use crate::default_client::CodexHttpClient;
|
||||
pub use crate::default_client::CodexRequestBuilder;
|
||||
pub use crate::error::StreamError;
|
||||
pub use crate::error::TransportError;
|
||||
pub const INTEGRITY_STATE_HEADER_NAME: &str = "X-OAI-IS";
|
||||
pub const INTEGRITY_STATE_UPDATE_HEADER_NAME: &str = "X-OAI-IS-Update";
|
||||
pub use crate::request::PreparedRequestBody;
|
||||
pub use crate::request::Request;
|
||||
pub use crate::request::RequestBody;
|
||||
|
||||
Reference in New Issue
Block a user