storage icon indicating copy to clipboard operation
storage copied to clipboard

add HEAD Mehthod to getObjects route

Open buschco opened this issue 3 years ago • 7 comments

What kind of change does this PR introduce?

Add a HEAD Method to getObject route so clients can get headers without requesting whole object.

What is the current behavior?

I get a 400 which is ok but a 405 would be better 😂

What is the new behavior?

A HEAD request just like the GET but without the body (see https://github.com/fastify/fastify/pull/2700/)

buschco avatar Jul 30 '22 08:07 buschco

Hi @buschco, I am worried that people might do a HEAD request and assume that an object exists at that route when it doesn't. For example /bucket/memes/cat-doesnt-exist.jpg will return a 200 which is confusing. If we are adding a HEAD request for getObject, I would rather only return a 200 if the object exists and the user has permissions to download it.

inian avatar Jul 31 '22 11:07 inian

@inian is this in the behavior of HEAD request in Fastify (or in general) returning 200 even if the GET would result in 4xx?

I could not find evidence for such behavior in the Fastify PR, am I missing something?

buschco avatar Aug 02 '22 17:08 buschco

Ah I just checked and it does look like Fastify returns the same status code as the GET endpoint rather than returning 200 always which is good.

Can you help check if the docs exported also have the HEAD method documented @buschco?

inian avatar Aug 05 '22 04:08 inian

Unfortunately the HEAD route is not in the generated static/api.json 😕

We could raise an inssue in fastify/swagger or keep it a hidden feature.

buschco avatar Aug 05 '22 08:08 buschco

Okay, I will merge the PR in. Can you open an issue in fastify/swagger and an issue in our repo so that we remember to add support this in our docs (or ensure this is fixed) after fastify adds support for it? Till then it can be a hidden feature ;)

inian avatar Aug 06 '22 07:08 inian

I raised the issue -> https://github.com/fastify/fastify-swagger/issues/648

thank you 🙂

buschco avatar Aug 06 '22 08:08 buschco

hmm the tests are failing for some reason. will merge once I debug why thats happening

inian avatar Aug 06 '22 09:08 inian

:tada: This PR is included in version 0.21.4 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Oct 07 '22 06:10 github-actions[bot]