Skip to content
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

fix: skip content-type header on unknown types #809

Merged

Conversation

clshortfuse
Copy link
Contributor

@clshortfuse clshortfuse commented Jan 1, 2021

Fixes #354

  • Only set 'Content-Type' header if mime type is known.
  • Remove testing for 'Content-Type' of unknown types.
  • Do not test against `application/octet-stream'.

Unknown media types should have content-type blank. Because
frameworks handle Content-Types differently, it is not possible to
standardize testing at the moment. Tests against
application/octet-stream can create false positives with Express
because of this.

https://tools.ietf.org/html/rfc7231#section-3.1.1.5
broofa/mime#139

This PR contains a:

  • bugfix
  • test update

Motivation / Use-Case

Breaking Changes

Unknown mime types (no extension or unknown extension) no longer produce a Content-Type with Connect/NodeJS API.

Additional Info

https://tools.ietf.org/html/rfc7231#section-3.1.1.5
broofa/mime#139

Fixes webpack#354

* Only set 'Content-Type' header if mime type is known.
* Remove testing for 'Content-Type' of unknown types.
* Do not test against `application/octet-stream'.

Unknown media types should have content-type blank. Because
frameworks handle Content-Types differently, it is not possible to
standardize testing at the moment. Tests against
`application/octet-stream` can create false positives with Express
because of this.

https://tools.ietf.org/html/rfc7231#section-3.1.1.5
broofa/mime#139
@clshortfuse clshortfuse requested a review from hiroppy as a code owner January 1, 2021 19:06
@codecov
Copy link

codecov bot commented Jan 1, 2021

Codecov Report

Merging #809 (ee7e198) into master (b1fe6bd) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #809   +/-   ##
=======================================
  Coverage   99.22%   99.22%           
=======================================
  Files          10       10           
  Lines         259      259           
  Branches       83       83           
=======================================
  Hits          257      257           
  Misses          2        2           
Impacted Files Coverage Δ
src/middleware.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1fe6bd...ee7e198. Read the comment docs.

@alexander-akait alexander-akait merged commit 5c9eee5 into webpack:master Jan 3, 2021
@alexander-akait
Copy link
Member

Big thanks for the work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: unknown mime type sets Content-Type as 'null; charset=UTF-8'
2 participants