This repository was archived by the owner on Mar 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change 33 Request ,
44 RequestInfo ,
55 Response ,
6+ withImmutableHeaders ,
67 withStringFormDataFiles ,
78} from "@miniflare/core" ;
89import {
@@ -226,7 +227,7 @@ export class Cache implements CacheInterface {
226227 headers,
227228 } ) ;
228229 if ( ! this . #formDataFiles) res = withStringFormDataFiles ( res ) ;
229- return res ;
230+ return withImmutableHeaders ( res ) ;
230231 }
231232
232233 async delete (
Original file line number Diff line number Diff line change @@ -238,6 +238,16 @@ test("Cache: match throws if attempting to load cached response created with Min
238238 "load cached data created with Miniflare 1 and must delete it." ,
239239 } ) ;
240240} ) ;
241+ test ( "Cache: match returns Response with immutable headers" , async ( t ) => {
242+ // https://github.com/cloudflare/miniflare/issues/365
243+ const { cache } = t . context ;
244+ await cache . put ( "http://localhost:8787/" , testResponse ( ) ) ;
245+ const cached = await cache . match ( "http://localhost:8787/" ) ;
246+ t . throws ( ( ) => cached ?. headers . set ( "X-Key" , "value" ) , {
247+ instanceOf : TypeError ,
248+ message : "immutable" ,
249+ } ) ;
250+ } ) ;
241251
242252const deleteMacro : Macro < [ RequestInfo ] , Context > = async ( t , req ) => {
243253 const { storage, cache } = t . context ;
You can’t perform that action at this time.
0 commit comments