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

change the mime type for dart source #19

Merged
merged 3 commits into from
Jul 22, 2018
Merged

change the mime type for dart source #19

merged 3 commits into from
Jul 22, 2018

Conversation

devoncarew
Copy link
Member

@devoncarew devoncarew commented May 28, 2018

Change the mime type for Dart source from application/dart to text/x-dart.

When working on a server serving up a browser based directory listing, I noticed that Dart source files were not displayed by the browser, but instead popped up a dialog asking to save them as binary content. Other source files (css, html, ...) were instead displayed in the browser.

The server was reporting application/dart as the mime type for Dart files. The application/ prefix is an indication to the browser that the file has binary content; as the browser didn't understand that binary format, it didn't attempt to display it.

Previously we had native processors of Dart files (and the application/dart mime type) - Dartium; however executable Dart on the web now just exists in the form of compiled JS files.

I think we should change the default mime type of Dart files to something that browsers will recognize as text based. From a quick perusal of other languages (and reading https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types), this would be something like text/x-dart.

@kevmoo @anders-sandholm

@anders-sandholm
Copy link

Generally SGTM.
What are potential negative implications from changing this?
In what other places should or would we need to change this as well, if any?

@kevmoo
Copy link
Member

kevmoo commented May 28, 2018

Thoughts @nex3 @natebosch @jakemac53 ?

Devon: what scenario are you working on here? Just curious...

@natebosch
Copy link
Member

This seems sensible to me. @vsmenon any concerns around source maps or anything?

@devoncarew
Copy link
Member Author

devoncarew commented May 28, 2018

Devon: what scenario are you working on here? Just curious...

I was working on a server that served file listings for directories (and file contents for files) - based on https://github.com/dart-lang/shelf_static. I noticed that the dart source files were the only file type that couldn't be displayed. Given that they're just straight text files, it was odd and a bit inconvenient. It's not really a deal breaker type of thing, but likely inconsistent with where we should be, given the current dart4web support (dart2js+DDC, rather than Dartium).

What are potential negative implications from changing this?

Good question! I don't know of any, but worth gathering input here.

In what other places should or would we need to change this as well, if any?

I found references here:

And there are likely others.

And in terms of other language mime types, I found: text/x-rust, text/x-rustsrc (http://codemirror.net/mode/rust/), text/x-go, text/x-swift, but did not do more than casual browsing.

@jakemac53
Copy link
Contributor

Sounds good to me, do we need to treat this as a breaking change?

@vsmenon
Copy link
Member

vsmenon commented May 29, 2018

Moving away from application/dart SGTM. That was purely a Dartium need back in the day.

Does the pubspec already imply that this package will not work with Dartium?

@natebosch
Copy link
Member

@vsmenon - the min SDK is 2.0.0-dev.20.0 which is past when we supported Dartium so I think this is relatively safe.

Technically this could be used on a server which still has a Dartium client, but I think the risk there is low.

@devoncarew devoncarew merged commit 7382696 into master Jul 22, 2018
@kevmoo kevmoo deleted the dart_mime_type branch May 29, 2019 19:05
mosuem pushed a commit to dart-lang/tools that referenced this pull request Aug 26, 2024
change the mime type for dart source
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.

7 participants