Azure / azure-service-bus

☁️ Azure Service Bus service issue tracking and samples
https://azure.microsoft.com/services/service-bus
MIT License
586 stars 776 forks source link

Different HTTP response code for HEAD and GET requests #713

Open rafajot1 opened 2 months ago

rafajot1 commented 2 months ago

Description

This is a follow-up to Azure support request ID | 2406240050002544

Actual Behavior

http status code for the same HEAD and GET http requests is different (404 NOT FOUND for HEAD and 200 OK for GET).

This seems to be a protocol violation: https://www.rfc-editor.org/rfc/rfc9110.html#name-head

Expected Behavior

Azure service bus should return the same HTTP response codes for HEAD and GET requests.

EldertGrootenboer commented 2 months ago

@rafajot1 Can you please provide more information on the scenario, and the URL(s) where this behavior is noticed?

rafajot1 commented 2 months ago

When it comes to examples I think the reported behaviour is true for most of cases but to be specific if I create SB with default settings and send request to the root URL it's already reproducible, for example:

$ curl -v https://rafal-testsb.servicebus.windows.net 2>&1|grep HTTP/1.1
> GET / HTTP/1.1
< HTTP/1.1 200 OK

$ curl -v -I https://rafal-testsb.servicebus.windows.net 2>&1|grep HTTP/1.1
> HEAD / HTTP/1.1
< HTTP/1.1 500 Internal Server Error
HTTP/1.1 500 Internal Server Error

I noticed that sometimes HEAD request to the root URL returns 404 response instead of 500. I don't really know when it's 404 and when it's 500. Anyway HEAD responses are different than GET responses (from my experience always 200 OK). I guess there may be other scenarios for example on the entity level instead of root URL where http response codes might be different than in the example above but still not the same for HEAD and GET.

There might be various reasons why having consistent responses for HEAD and GET can be desirable. Examples that come to my mind are:

EldertGrootenboer commented 2 months ago

Thank you for your feedback. We have opened an investigation task for this in our backlog, and will update this issue when we have more information.