cloud-gov / secureproxy-boshrelease

Other
1 stars 4 forks source link

only add Content-Type header when respnose body is present #82

Closed markdboyd closed 5 months ago

markdboyd commented 5 months ago

Changes Proposed

Related to https://github.com/cloud-gov/cg-secureproxy-boshrelease/issues/81

The discussion in #81 highlights a potential bug in this proxy: it always adds a default Content-Type header to the response, even in cases like HTTP 204/304 responses which have no response body and thus for which a Content-Type header is inappropriate.

This PR updates the Nginx configuration to only set a default Content-Type header when the response body length is not 0, which should prevent undesirable behavior on 204/304 responses.

Security Considerations

It seems like adding a Content-Type header was done to resolve a POAM: https://github.com/cloud-gov/product/issues/540

At the same time, it seems like the Content-Type header itself may have been an afterthought: https://github.com/cloud-gov/cg-secureproxy-boshrelease/pull/6

But for responses where the response body length is 0, I don't see how adding a Content-Type header is ever appropriate.