Download codex-rs/codex-mcp/src/executor_environment_http_client.rs from SaylorTwift/codex: direct link, hf CLI and curl.
- Browser
- Download file 1.47 kB
-
https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/codex-mcp/src/executor_environment_http_client.rs
- Command line
-
hf download hf://SaylorTwift/codex/codex-rs/codex-mcp/src/executor_environment_http_client.rs
-
curl -L -o executor_environment_http_client.rs https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/codex-mcp/src/executor_environment_http_client.rs
1.47 kB
| use std::sync::Arc; | |
| use codex_exec_server::ExecServerError; | |
| use codex_exec_server::HttpClient; | |
| use codex_exec_server::HttpHeader; | |
| use codex_exec_server::HttpRequestParams; | |
| use codex_exec_server::HttpRequestResponse; | |
| use codex_exec_server::HttpResponseBodyStream; | |
| use futures::future::BoxFuture; | |
| pub(crate) struct ExecutorEnvironmentHttpClient { | |
| pub(crate) bearer_token_env_var: String, | |
| pub(crate) http_client: Arc<dyn HttpClient>, | |
| } | |
| impl ExecutorEnvironmentHttpClient { | |
| fn attach_authorization(&self, params: &mut HttpRequestParams) { | |
| params | |
| .headers | |
| .retain(|header| !header.name.eq_ignore_ascii_case("authorization")); | |
| params.headers.push(HttpHeader { | |
| name: "authorization".to_string(), | |
| value: "Bearer ".to_string(), | |
| value_env_var: Some(self.bearer_token_env_var.clone()), | |
| }); | |
| } | |
| } | |
| impl HttpClient for ExecutorEnvironmentHttpClient { | |
| fn http_request( | |
| &self, | |
| mut params: HttpRequestParams, | |
| ) -> BoxFuture<'_, Result<HttpRequestResponse, ExecServerError>> { | |
| self.attach_authorization(&mut params); | |
| self.http_client.http_request(params) | |
| } | |
| fn http_request_stream( | |
| &self, | |
| mut params: HttpRequestParams, | |
| ) -> BoxFuture<'_, Result<(HttpRequestResponse, HttpResponseBodyStream), ExecServerError>> { | |
| self.attach_authorization(&mut params); | |
| self.http_client.http_request_stream(params) | |
| } | |
| } | |