-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for query params on s3 requests and body to be passed through #134
base: master
Are you sure you want to change the base?
Add support for query params on s3 requests and body to be passed through #134
Conversation
@@ -68,7 +68,9 @@ export default function s3HandlerFactory({ | |||
? utils.resolveParams(`${resolvedEndpoint}/{file}`, ctx.params) | |||
: resolvedEndpoint; // Bucket operations | |||
|
|||
const headers = ctx.request.headers || {}; | |||
const headers = { | |||
...(ctx.request?.headers?.range && { range: ctx.request.headers.range }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm. it looks like this should have worked in the past as well as we're passing on all the headers? Am I missing something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the current HEAD just passes on the range headers:-
cloudworker-proxy/src/handlers/s3.ts
Line 74 in 10c4ffc
headers.range = ctx.request.headers.range; |
I changed it to pass on everything in this PR earlier. Then I realised that broke the AWS signing so I reverted back to jsut the range headers. Will need to fix at some point but I am not sure which headers break the signer yet. An aws4fetch-like lib suggests the host header is a problem jamesmbourne/aws4-axios#110
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the current HEAD initializes the headers to {} and then adds a range header only. We are indeed missing useful features like If-None-Match
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could add if-none-match and other headers but I am unsure of whether they are capitalised or not
} | ||
|
||
const response = await aws.fetch(url, { | ||
const response = await aws.fetch(url + (ctx.request.search || ''), { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this 1 main the main thing added, search params
method: ctx.method || ctx.request.method, | ||
headers, | ||
...(ctx.request.body && { body: ctx.request.body }), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and body for PUT requests
Current S3 handler ends up stripping query/body/header parameters which are useful for various s3 API functions.