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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Angular 13 sending application/octet-stream MIME type for unknown files #22091

Closed
1 of 15 tasks
acalvo opened this issue Nov 4, 2021 · 3 comments
Closed
1 of 15 tasks

Comments

@acalvo
Copy link
Contributor

acalvo commented Nov 4, 2021

馃悶 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, the previous version in which this bug was not present was: 12.x

Description

Until now, a file without extension was served by Angular in dev mode (ng serve) with the ; charset=UTF8 Content-Type header, which enabled the MIME type sniffing making the browser treat it correctly. With Angular 13 the header changed to application/octet-stream which made the browser try to download it.

We set the appropriate headers to file in production, but this can't be done in the dev server as long as I know, so we relied in MIME type sniffing for dev mode until now.

馃敩 Minimal Reproduction

Create any asset without extension (for example a simple html file without extension), run ng serve and navigate to that URL. In Angular12 it'll be displayed, in Angular13 the browser will ask to download it.

馃敟 Exception or Error

馃實 Your Environment


Angular CLI: 13.0.1
Node: 14.17.1
Package Manager: npm 7.24.1
OS: darwin x64

Angular: 13.0.0
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, localize, material, platform-browser
... platform-browser-dynamic, router, service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1202.7
@angular-devkit/build-angular   13.0.1
@angular-devkit/core            12.2.7
@angular-devkit/schematics      13.0.1
@angular/cli                    13.0.1
@schematics/angular             13.0.1
rxjs                            6.6.7
typescript                      4.4.4

Anything else relevant?

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Nov 5, 2021

Hi @acalvo,

Using application/octet-stream in this case seems to be the correct behaviour for files without extensions, especially considering the webpack-dev-server uses Express engine under the hood. Related test in webpack-dev-middleware.

This also aligns with the spec found in https://tools.ietf.org/html/rfc2045

Any entity with an unrecognized Content-Transfer-Encoding must be treated as if it has a Content-Type of "application/octet-stream", regardless of what the Content-Type header field actually says.

Files without extensions are also handled different from one server engine to another, there is a good comparison here. I therefore don't recommand using a file without extension.

@alan-agius4
Copy link
Collaborator

Closing as this seems to be working as design by Express engine.

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants