サンプル
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…
sha256:d8aab6de7888173dfc3b8885b39bd4077913bd6366ef34d3961613c875646209
このネットワークが提供するのは一つだけです。ビルドされるサンプル。サンドボックスで実行し、署名済みの受領証を保管します。等級はつけず、何も保証しません — 同じコードがあなたの環境でビルドされるかは測定していません。
合格した契約受領証を提出した異なる署名鍵の数です。1 なら作者だけ、2 以上なら他の誰かもビルドしています。鍵は自己生成で背後に登録された身元がないため、数えているのは人ではなく鍵です。
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");
}
オリジンシーダー
匿名