샘플
hono 4.13.7: RETAINED_304_HEADERS
검증된 샘플 — npm hono 4.13.7: RETAINED_304_HEADERS. node 22 · linux debian/x64 · docker에서 contract를 실행해 통과했습니다: RETAINED_304_HEADERS contains standard HTTP 304…
sha256:eed308749cea80b1e7ae0c157daeca63c96143a3d4d954633f719afa20eafe58
이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다.
통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다.
MIT-0
실행 증거
선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.
- 증거 기준
- 서명된 컨트랙트 통과
- 검증 영수증
- 1
- 빌드한 서명 키
- 1
선언된 환경
linux 24 · ubuntu · glibc 2.39 x64 npm
검증 실행 환경
| 환경 | 컨트랙트 | 단계 | 실행일 |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-09-06 |
케이스
HOW- 목표
- verify hono.RETAINED_304_HEADERS in pkg:npm/hono@4.13.7
- 패키지
- 심벌
-
- hono.RETAINED_304_HEADERS
- 생성일
- 2026-09-06T04:35:42Z
컨트랙트
- RETAINED_304_HEADERS contains standard HTTP 304 response headers (cache-control, content-location, date, etag, expires, vary)
- etag middleware preserves default RETAINED_304_HEADERS and strips other response headers on 304 Not Modified
- etag middleware preserves additional custom headers on 304 responses when options.retainedHeaders extends RETAINED_304_HEADERS
- etag middleware strips default headers on 304 responses when options.retainedHeaders is explicitly restricted
파일
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- src/index.mjs
- test/contract.mjs
소스
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 hono.RETAINED_304_HEADERS in pkg:npm/hono@4.13.7
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/hono@4.13.7
Demonstrate these symbols/APIs:
- hono.RETAINED_304_HEADERS
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:9fd0b213e5fa6016b9632dcdc495ee7e7f90eea12c8ecb6cb0ec132a84765062","contract":["RETAINED_304_HEADERS contains standard HTTP 304 response headers (cache-control, content-location, date, etag, expires, vary)","etag middleware preserves default RETAINED_304_HEADERS and strips other response headers on 304 Not Modified","etag middleware preserves additional custom headers on 304 responses when options.retainedHeaders extends RETAINED_304_HEADERS","etag middleware strips default headers on 304 responses when options.retainedHeaders is explicitly restricted"],"goal":"verify hono.RETAINED_304_HEADERS in pkg:npm/hono@4.13.7","kind":"HOW","packages":["pkg:npm/hono@4.13.7"],"schemaVersion":1,"symbols":["hono.RETAINED_304_HEADERS"]},"contractCommand":["node","test/contract.mjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"npm","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/hono@4.13.7"],"schemaVersion":1,"subject":"pkg:npm/hono@4.13.7","symbols":["hono.RETAINED_304_HEADERS"],"verifierAdapter":"node-typescript@1"}
{
"name": "sample-hono-retained-304-headers",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "sample-hono-retained-304-headers",
"version": "1.0.0",
"license": "MIT-0",
"dependencies": {
"hono": "4.13.7"
}
},
"node_modules/hono": {
"version": "4.13.7",
"resolved": "https://registry.npmjs.org/hono/-/hono-4.13.7.tgz",
"integrity": "sha512-c8/gF9ac8Y78/agExVocyLevgR+JlpNB444Py0FSX8pJoPdYUfUzRcXtYEYGwt6l19qIlVZPN5Mfsw9jFShmQQ==",
"license": "MIT",
"engines": {
"node": ">=16.9.0"
}
}
}
}
{
"name": "sample-hono-retained-304-headers",
"version": "1.0.0",
"private": true,
"license": "MIT-0",
"dependencies": {
"hono": "4.13.7"
}
}
{
"schemaVersion": 1,
"goal": "verify hono.RETAINED_304_HEADERS in pkg:npm/hono@4.13.7",
"kind": "HOW",
"packages": [
"pkg:npm/hono@4.13.7"
],
"symbols": [
"hono.RETAINED_304_HEADERS"
]
}
import { Hono } from 'hono';
import { RETAINED_304_HEADERS, etag } from 'hono/etag';
/**
* Creates a Hono application with configured etag middleware.
*
* @param {object} [options] - Options passed to etag middleware.
* @returns {Hono}
*/
export function createApp(options) {
const app = new Hono();
app.use('*', etag(options));
return app;
}
export { RETAINED_304_HEADERS, etag, Hono };
import assert from 'node:assert/strict';
import { createApp, RETAINED_304_HEADERS, etag, Hono } from '../src/index.mjs';
async function testAll() {
// Contract assertion 1: RETAINED_304_HEADERS contains standard HTTP 304 response headers
{
assert.ok(Array.isArray(RETAINED_304_HEADERS), 'RETAINED_304_HEADERS must be an array');
const expectedHeaders = ['cache-control', 'content-location', 'date', 'etag', 'expires', 'vary'];
assert.equal(RETAINED_304_HEADERS.length, expectedHeaders.length, 'RETAINED_304_HEADERS must have 6 standard headers');
for (const header of expectedHeaders) {
assert.ok(
RETAINED_304_HEADERS.includes(header),
`RETAINED_304_HEADERS must include ${header}`
);
}
}
// Contract assertion 2: etag middleware preserves default RETAINED_304_HEADERS and strips other response headers on 304 Not Modified
{
const app = createApp();
app.get('/resource', (c) => {
c.header('Cache-Control', 'public, max-age=3600');
c.header('Vary', 'Accept-Encoding');
c.header('X-Custom-Ephemeral', 'temporary-data');
return c.text('resource content');
});
const initialRes = await app.request('http://localhost/resource');
assert.equal(initialRes.status, 200, 'Initial request should return 200 OK');
const etagHeader = initialRes.headers.get('ETag');
assert.ok(etagHeader, 'Initial response must include an ETag header');
assert.equal(initialRes.headers.get('Cache-Control'), 'public, max-age=3600');
assert.equal(initialRes.headers.get('Vary'), 'Accept-Encoding');
assert.equal(initialRes.headers.get('X-Custom-Ephemeral'), 'temporary-data');
const conditionalRes = await app.request('http://localhost/resource', {
headers: { 'If-None-Match': etagHeader }
});
assert.equal(conditionalRes.status, 304, 'Conditional request should return 304 Not Modified');
assert.equal(conditionalRes.headers.get('ETag'), etagHeader, 'ETag must be retained');
assert.equal(conditionalRes.headers.get('Cache-Control'), 'public, max-age=3600', 'Cache-Control in RETAINED_304_HEADERS must be retained');
assert.equal(conditionalRes.headers.get('Vary'), 'Accept-Encoding', 'Vary in RETAINED_304_HEADERS must be retained');
assert.equal(conditionalRes.headers.get('X-Custom-Ephemeral'), null, 'Headers not in RETAINED_304_HEADERS must be stripped');
}
// Contract assertion 3: etag middleware preserves additional custom headers on 304 responses when options.retainedHeaders extends RETAINED_304_HEADERS
{
const app = createApp({
retainedHeaders: [...RETAINED_304_HEADERS, 'x-custom-retained']
});
app.get('/custom', (c) => {
c.header('Cache-Control', 'private, no-transform');
c.header('X-Custom-Retained', 'keep-me');
c.header('X-Custom-Discarded', 'discard-me');
return c.text('custom resource');
});
const initialRes = await app.request('http://localhost/custom');
assert.equal(initialRes.status, 200);
const etagHeader = initialRes.headers.get('ETag');
assert.ok(etagHeader);
const conditionalRes = await app.request('http://localhost/custom', {
headers: { 'If-None-Match': etagHeader }
});
assert.equal(conditionalRes.status, 304);
assert.equal(conditionalRes.headers.get('Cache-Control'), 'private, no-transform', 'Default retained header preserved');
assert.equal(conditionalRes.headers.get('X-Custom-Retained'), 'keep-me', 'Custom extended header must be retained');
assert.equal(conditionalRes.headers.get('X-Custom-Discarded'), null, 'Non-retained header must be stripped');
}
// Contract assertion 4: etag middleware strips default headers on 304 responses when options.retainedHeaders is explicitly restricted
{
const app = createApp({
retainedHeaders: ['etag']
});
app.get('/restricted', (c) => {
c.header('Cache-Control', 'public, max-age=1800');
c.header('Vary', 'User-Agent');
return c.text('restricted resource');
});
const initialRes = await app.request('http://localhost/restricted');
assert.equal(initialRes.status, 200);
const etagHeader = initialRes.headers.get('ETag');
assert.ok(etagHeader);
const conditionalRes = await app.request('http://localhost/restricted', {
headers: { 'If-None-Match': etagHeader }
});
assert.equal(conditionalRes.status, 304);
assert.equal(conditionalRes.headers.get('ETag'), etagHeader, 'Explicitly retained ETag is preserved');
assert.equal(conditionalRes.headers.get('Cache-Control'), null, 'Cache-Control stripped when excluded from restricted retainedHeaders');
assert.equal(conditionalRes.headers.get('Vary'), null, 'Vary stripped when excluded from restricted retainedHeaders');
}
console.log('All contract assertions for hono.RETAINED_304_HEADERS passed.');
}
testAll().catch((err) => {
console.error('Contract test failed:', err);
process.exit(1);
});
오리진 시더
익명