handleGET: hide S3 bucket responses

This commit is contained in:
Peter Cai 2021-11-24 19:01:46 -05:00
parent 1af297c537
commit 3b1602d2bc
1 changed files with 11 additions and 1 deletions

View File

@ -37,7 +37,17 @@ handleGET = (request) ->
return new Response "Invalid URL", return new Response "Invalid URL",
status: 404 status: 404
return await s3.getObject url.pathname[1...], {} resp = await s3.getObject url.pathname[1...], {}
if not resp.ok
headers = new Headers resp.headers
headers.set "Content-Length", 0
return new Response null,
status: resp.status
statusText: resp.statusText
headers: headers
else
return resp
handlePUT = (request) -> handlePUT = (request) ->
url = new URL request.url url = new URL request.url