Skip to content

BUG: lambdaurl.Wrap does not add Content-Type or Content-Length headers like http.ResponseWriter does #508

Closed
@xremming

Description

@xremming

The http.ResponseWriter implementation says the following thing about Content-Type header (and it actually has a note about Content-Length too).

If WriteHeader has not yet been called, Write calls
WriteHeader(http.StatusOK) before writing the data. If the Header
does not contain a Content-Type line, Write adds a Content-Type set
to the result of passing the initial 512 bytes of written data to
DetectContentType. Additionally, if the total size of all written
data is under a few KB and there are no Flush calls, the
Content-Length header is added automatically.

As of right now the lambdaurl.Wrap implementation completely misses this and causes all content without an explicit Content-Type header to get it with application/json. Which is different and incorrect when compared to how the http.Handler normally works.

A simple repro for this is to use http.FileServer with e.g. HTML files. The HTML files will not be loaded by the browser properly as the response will have Content-Type: application/json header in it but when running the same handler normally it will work fine.

Metadata

Metadata

Assignees

Labels

type/lambdaurlIssue or feature request related to the lambdaurl packagetype/ux

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions