Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions codex-rs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions codex-rs/core/src/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,8 @@ pub const FEATURES: &[FeatureSpec] = &[
FeatureSpec {
id: Feature::EnableRequestCompression,
key: "enable_request_compression",
stage: Stage::UnderDevelopment,
default_enabled: false,
stage: Stage::Stable,
default_enabled: true,
},
FeatureSpec {
id: Feature::Collab,
Expand Down
1 change: 1 addition & 0 deletions codex-rs/core/tests/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ tokio-tungstenite = { workspace = true }
walkdir = { workspace = true }
wiremock = { workspace = true }
shlex = { workspace = true }
zstd = { workspace = true }

[dev-dependencies]
pretty_assertions = { workspace = true }
Expand Down
36 changes: 33 additions & 3 deletions codex-rs/core/tests/common/responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,32 @@ impl ResponseMock {
#[derive(Debug, Clone)]
pub struct ResponsesRequest(wiremock::Request);

fn is_zstd_encoding(value: &str) -> bool {
value
.split(',')
.any(|entry| entry.trim().eq_ignore_ascii_case("zstd"))
}

fn decode_body_bytes(body: &[u8], content_encoding: Option<&str>) -> Vec<u8> {
if content_encoding.is_some_and(is_zstd_encoding) {
zstd::stream::decode_all(std::io::Cursor::new(body)).unwrap_or_else(|err| {
panic!("failed to decode zstd request body: {err}");
})
} else {
body.to_vec()
}
}

impl ResponsesRequest {
pub fn body_json(&self) -> Value {
self.0.body_json().unwrap()
let body = decode_body_bytes(
&self.0.body,
self.0
.headers
.get("content-encoding")
.and_then(|value| value.to_str().ok()),
);
serde_json::from_slice(&body).unwrap()
}

pub fn body_bytes(&self) -> Vec<u8> {
Expand All @@ -105,7 +128,7 @@ impl ResponsesRequest {
}

pub fn input(&self) -> Vec<Value> {
self.0.body_json::<Value>().unwrap()["input"]
self.body_json()["input"]
.as_array()
.expect("input array not found in request")
.clone()
Expand Down Expand Up @@ -1083,7 +1106,14 @@ fn validate_request_body_invariants(request: &wiremock::Request) {
if request.method != "POST" || !request.url.path().ends_with("/responses") {
return;
}
let Ok(body): Result<Value, _> = request.body_json() else {
let body_bytes = decode_body_bytes(
&request.body,
request
.headers
.get("content-encoding")
.and_then(|value| value.to_str().ok()),
);
let Ok(body): Result<Value, _> = serde_json::from_slice(&body_bytes) else {
return;
};
let Some(items) = body.get("input").and_then(Value::as_array) else {
Expand Down
Loading