@@ -24,6 +24,8 @@ interface BucketResponse {
2424
2525interface ObjectInfoResponse {
2626 bucket_id ?: string
27+ cache_control ?: string | null
28+ content_type ?: string | null
2729 metadata ?: Record < string , unknown > | null
2830 name ?: string
2931}
@@ -736,6 +738,75 @@ describeAcceptance(
736738 }
737739 } )
738740
741+ it ( 'serves updated cache-control after copy overwrites object metadata' , async ( ) => {
742+ const client = createRestClient ( )
743+ const token = requireServiceKey ( )
744+ const bucketName = uniqueBucketName ( 'copycache' )
745+ const objectKey = uniqueObjectKey ( 'copy-cache' )
746+ const initialCacheControl = 'max-age=60'
747+ const updatedCacheControl = 'max-age=604800'
748+ const payload = 'cache-control-copy-body'
749+
750+ try {
751+ await createRestBucket ( bucketName , { isPublic : false } )
752+
753+ await client . request ( 'POST' , `/object/${ bucketName } /${ encodePathSegments ( objectKey ) } ` , {
754+ body : payload ,
755+ expectedStatus : 200 ,
756+ headers : {
757+ 'cache-control' : initialCacheControl ,
758+ 'content-type' : 'text/plain' ,
759+ 'x-upsert' : 'true' ,
760+ } ,
761+ token,
762+ } )
763+
764+ const beforeCopy = await client . request (
765+ 'GET' ,
766+ `/object/authenticated/${ bucketName } /${ encodePathSegments ( objectKey ) } ` ,
767+ { expectedStatus : 200 , token }
768+ )
769+ expect ( beforeCopy . body ) . toBe ( payload )
770+ expect ( beforeCopy . headers . get ( 'cache-control' ) ) . toBe ( initialCacheControl )
771+
772+ await client . request ( 'POST' , '/object/copy' , {
773+ body : {
774+ bucketId : bucketName ,
775+ copyMetadata : false ,
776+ destinationKey : objectKey ,
777+ metadata : {
778+ cacheControl : updatedCacheControl ,
779+ } ,
780+ sourceKey : objectKey ,
781+ } ,
782+ expectedStatus : 200 ,
783+ headers : {
784+ 'x-upsert' : 'true' ,
785+ } ,
786+ token,
787+ } )
788+
789+ const afterCopy = await client . request (
790+ 'GET' ,
791+ `/object/authenticated/${ bucketName } /${ encodePathSegments ( objectKey ) } ` ,
792+ { expectedStatus : 200 , token }
793+ )
794+ expect ( afterCopy . body ) . toBe ( payload )
795+ expect ( afterCopy . headers . get ( 'cache-control' ) ) . toBe ( updatedCacheControl )
796+ expect ( afterCopy . headers . get ( 'content-type' ) ) . toBe ( 'text/plain' )
797+
798+ const info = await client . request < ObjectInfoResponse > (
799+ 'GET' ,
800+ `/object/info/authenticated/${ bucketName } /${ encodePathSegments ( objectKey ) } ` ,
801+ { expectedStatus : 200 , token }
802+ )
803+ expect ( info . json ?. cache_control ) . toBe ( updatedCacheControl )
804+ expect ( info . json ?. content_type ) . toBe ( 'text/plain' )
805+ } finally {
806+ await cleanupRestResources ( bucketName , [ objectKey ] , client )
807+ }
808+ } )
809+
739810 it ( 'enforces bucket file-size limits on REST uploads' , async ( ) => {
740811 const config = getAcceptanceConfig ( )
741812 const client = createRestClient ( )
0 commit comments