mirror of
https://github.com/zyycn/codex-proxy-rs.git
synced 2026-11-13 16:07:29 +00:00
fix: allow large OpenAI request bodies
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
//! OpenAI 兼容 API 路由。
|
||||
|
||||
use axum::{
|
||||
extract::DefaultBodyLimit,
|
||||
routing::{get, post},
|
||||
Router,
|
||||
};
|
||||
@@ -22,4 +23,5 @@ pub fn router() -> Router<AppState> {
|
||||
.route("/v1/models/catalog", get(model_catalog))
|
||||
.route("/v1/models/{model_id}", get(model_detail))
|
||||
.route("/v1/models/{model_id}/info", get(model_info))
|
||||
.layer(DefaultBodyLimit::disable())
|
||||
}
|
||||
|
||||
@@ -59,6 +59,30 @@ async fn responses_route_should_reject_unknown_models_with_openai_error() {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn responses_route_should_accept_body_larger_than_axum_default_limit() {
|
||||
let (app, api_key, _dir) = test_app_with_client_api_key().await;
|
||||
let large_input = "x".repeat(3 * 1024 * 1024);
|
||||
let body = serde_json::json!({
|
||||
"model": "unknown-model",
|
||||
"input": large_input,
|
||||
})
|
||||
.to_string();
|
||||
let response = app
|
||||
.oneshot(
|
||||
Request::builder()
|
||||
.method("POST")
|
||||
.uri("/v1/responses")
|
||||
.header("authorization", format!("Bearer {api_key}"))
|
||||
.header("content-type", "application/json")
|
||||
.body(Body::from(body))
|
||||
.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(response.status(), StatusCode::NOT_FOUND);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn responses_route_should_terminate_generated_stream_errors_with_done_marker() {
|
||||
let (app, api_key, _dir) = test_app_with_client_api_key().await;
|
||||
|
||||
Reference in New Issue
Block a user