샘플
http 1.4.0: http::Response
검증된 샘플 — cargo http 1.4.0: http::Response. rust 1 · linux alpine/x64 · docker에서 contract를 실행해 통과했습니다: http::Response::new and Response::default construct 200…
sha256:d8aab6de7888173dfc3b8885b39bd4077913bd6366ef34d3961613c875646209
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux · alpine · musl x64 cargo
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| rust 1 · linux alpine/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · cargo@1rust:1-alpine@sha256:a10e64dd139b… |
2026-11-17 |
케이스
HOW- 목표
- verify http::Response in pkg:cargo/http@1.4.0
- 패키지
- 심벌
-
- http::Response
- 생성일
- 2026-11-17T00:17:47Z
컨트랙트
- http::Response::new and Response::default construct 200 OK HTTP/1.1 responses with empty headers and the provided or default body
- http::Response::builder configures status, HTTP version, headers, and typed extensions, and returns Err on invalid header values
- http::Response mutable accessors update status_mut, version_mut, headers_mut, extensions_mut, and body_mut in place
- http::Response::into_parts, Response::from_parts, and Response::map decompose, reconstruct, and transform response bodies while preserving metadata
파일
- Cargo.lock
- Cargo.toml
- PROMPT.md
- csx.json
- spec.json
- src/lib.rs
- test/contract.rs
소스
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "bytes"
version = "1.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
[[package]]
name = "http"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a"
dependencies = [
"bytes",
"itoa",
]
[[package]]
name = "itoa"
version = "1.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
[[package]]
name = "sample-http-response"
version = "1.0.0"
dependencies = [
"http",
]
[package]
name = "sample-http-response"
version = "1.0.0"
edition = "2021"
publish = false
[dependencies]
http = "=1.4.0"
[[bin]]
name = "contract"
path = "test/contract.rs"
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify http::Response in pkg:cargo/http@1.4.0
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:cargo/http@1.4.0
Demonstrate these symbols/APIs:
- http::Response
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:8ded6a574edb9129a1bda4cc72a896a50bf494d6013f8e055518f4451ba4f5c7","contract":["http::Response::new and Response::default construct 200 OK HTTP/1.1 responses with empty headers and the provided or default body","http::Response::builder configures status, HTTP version, headers, and typed extensions, and returns Err on invalid header values","http::Response mutable accessors update status_mut, version_mut, headers_mut, extensions_mut, and body_mut in place","http::Response::into_parts, Response::from_parts, and Response::map decompose, reconstruct, and transform response bodies while preserving metadata"],"goal":"verify http::Response in pkg:cargo/http@1.4.0","kind":"HOW","packages":["pkg:cargo/http@1.4.0"],"schemaVersion":1,"symbols":["http::Response"]},"contractCommand":["cargo","run","--offline"],"environment":{"arch":"x64","distro":"alpine","ecosystem":"cargo","libc":"musl","os":"linux","packageManager":"cargo","schemaVersion":1},"license":"MIT-0","packages":["pkg:cargo/http@1.4.0"],"schemaVersion":1,"subject":"pkg:cargo/http@1.4.0","symbols":["http::Response"],"verifierAdapter":"cargo@1"}
{
"schemaVersion": 1,
"goal": "verify http::Response in pkg:cargo/http@1.4.0",
"kind": "HOW",
"packages": [
"pkg:cargo/http@1.4.0"
],
"symbols": [
"http::Response"
]
}
//! Clean-room verification sample for http::Response.
pub use http::Response;
use http::header::{HeaderValue, CONTENT_LENGTH, CONTENT_TYPE, LOCATION};
use http::{Response, StatusCode, Version};
#[derive(Clone, Debug, PartialEq, Eq)]
struct TraceId(u64);
fn main() {
// 1. Response::new constructs a 200 OK HTTP/1.1 response with empty headers and the given body
let basic = Response::new("hello world");
assert_eq!(basic.status(), StatusCode::OK);
assert_eq!(basic.version(), Version::HTTP_11);
assert!(basic.headers().is_empty());
assert_eq!(*basic.body(), "hello world");
assert_eq!(basic.into_body(), "hello world");
// 2. Response::default constructs a default 200 OK response when the body implements Default
let default_resp: Response<Vec<u8>> = Response::default();
assert_eq!(default_resp.status(), StatusCode::OK);
assert_eq!(default_resp.version(), Version::HTTP_11);
assert!(default_resp.body().is_empty());
// 3. Response::builder configures status, version, headers, and typed extensions, and rejects invalid header values
let built = Response::builder()
.status(StatusCode::CREATED)
.version(Version::HTTP_2)
.header(CONTENT_TYPE, "application/json")
.header(LOCATION, "https://example.com/items/42")
.extension(TraceId(42))
.body(String::from("{\"id\":42}"))
.expect("valid response builder");
assert_eq!(built.status(), StatusCode::CREATED);
assert_eq!(built.version(), Version::HTTP_2);
assert_eq!(
built.headers().get(CONTENT_TYPE),
Some(&HeaderValue::from_static("application/json"))
);
assert_eq!(
built.headers().get(LOCATION),
Some(&HeaderValue::from_static("https://example.com/items/42"))
);
assert_eq!(built.extensions().get::<TraceId>(), Some(&TraceId(42)));
assert_eq!(built.body(), "{\"id\":42}");
let invalid = Response::builder()
.header("x-invalid", "bad\nvalue")
.body(());
assert!(invalid.is_err());
// 4. Mutable accessors update status, version, headers, extensions, and body in place
let mut mutable = Response::new(String::from("initial"));
*mutable.status_mut() = StatusCode::ACCEPTED;
*mutable.version_mut() = Version::HTTP_10;
mutable
.headers_mut()
.insert(CONTENT_TYPE, HeaderValue::from_static("text/plain"));
mutable.extensions_mut().insert(TraceId(99));
mutable.body_mut().push_str(" payload");
assert_eq!(mutable.status(), StatusCode::ACCEPTED);
assert_eq!(mutable.version(), Version::HTTP_10);
assert_eq!(
mutable.headers().get(CONTENT_TYPE),
Some(&HeaderValue::from_static("text/plain"))
);
assert_eq!(mutable.extensions().get::<TraceId>(), Some(&TraceId(99)));
assert_eq!(mutable.body(), "initial payload");
// 5. into_parts, from_parts, and map transform response bodies while preserving metadata
let (mut parts, body_text) = mutable.into_parts();
assert_eq!(parts.status, StatusCode::ACCEPTED);
parts.status = StatusCode::OK;
let body_len = body_text.len();
parts.headers.insert(
CONTENT_LENGTH,
HeaderValue::from_str(&body_len.to_string()).expect("valid content-length"),
);
let reconstructed = Response::from_parts(parts, body_text);
let byte_response: Response<Vec<u8>> = reconstructed.map(String::into_bytes);
assert_eq!(byte_response.status(), StatusCode::OK);
assert_eq!(byte_response.version(), Version::HTTP_10);
assert_eq!(
byte_response.headers().get(CONTENT_LENGTH),
Some(&HeaderValue::from_static("15"))
);
assert_eq!(
byte_response.extensions().get::<TraceId>(),
Some(&TraceId(99))
);
assert_eq!(byte_response.body().as_slice(), b"initial payload");
}
오리진 시더
익명