Closed Bug 1362504 Opened 7 years ago Closed 7 years ago

JSON Viewer should save using the original mime type

Categories

(DevTools :: JSON Viewer, defect)

defect
Not set
normal

Tracking

(firefox55 fixed)

RESOLVED FIXED
Firefox 55
Tracking Status
firefox55 --- fixed

People

(Reporter: Oriol, Assigned: Oriol)

References

Details

Attachments

(1 file, 2 obsolete files)

Bug 1349437 enabled saving the JSON contents via Ctrl+S in the JSON Viewer.

The problem is that it downloads with the application/json mime type, which forces a .json extension, even if the original type was application/manifest+json or application/vnd.mozilla.json.view.

The original type is available in the chrome process, but it's needed in the content one (see bug 1349437 comment 9).
Attached patch json-save-with-type.patch (obsolete) — Splinter Review
I noticed converter-child.js has access to the HTTP headers, this can be used to obtain the content type. For data URIs I use a regexp. And application/json is the fallback value if I missed some other case.
Assignee: nobody → oriol-bugzilla
Status: NEW → ASSIGNED
Attachment #8865028 - Flags: review?(odvarko)
Attached patch json-save-with-type-v2.patch (obsolete) — Splinter Review
Adding a try..catch in case getResponseHeader throws (e.g. if you enable the JSON Viewer for "application/x-unknown-content-type", and the server doesn't send the Content-Type header).
Attachment #8865028 - Attachment is obsolete: true
Attachment #8865028 - Flags: review?(odvarko)
Attachment #8865056 - Flags: review?(odvarko)
Comment on attachment 8865056 [details] [diff] [review]
json-save-with-type-v2.patch

Review of attachment 8865056 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good to me.

Please see one inline comment

R+ assuming try is green

Try push:
https://treeherder.mozilla.org/#/jobs?repo=try&revision=0d6d9298f14c5d708ea80a88743fb799c30d5eae

Honza

::: devtools/client/jsonview/converter-child.js
@@ +101,5 @@
> +    // which has been replaced by application/vnd.mozilla.json.view
> +    let originalType;
> +    if (request instanceof Ci.nsIHttpChannel) {
> +      try {
> +        originalType = request.getResponseHeader('Content-Type');

nit: use quotes for strings => "Content-Type"
Attachment #8865056 - Flags: review?(odvarko) → review+
Fixed, but I don't see why simple quotes are considered bad. Now I hope the linter stops complaining. How to run linter tests locally?
Attachment #8865056 - Attachment is obsolete: true
Attachment #8865454 - Flags: review?(odvarko)
Attachment #8865454 - Flags: review?(odvarko) → review+
(In reply to Oriol from comment #4)
> Fixed, but I don't see why simple quotes are considered bad.
It's just part of our code style rules.

> Now I hope the linter stops complaining. How to run linter tests locally?
See this MDN page
https://developer.mozilla.org/en-US/docs/ESLint

Honza
Keywords: checkin-needed
Pushed by ryanvm@gmail.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/a5a5759c9547
Let JSON Viewer save with original content type. r=Honza
Keywords: checkin-needed
https://hg.mozilla.org/mozilla-central/rev/a5a5759c9547
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 55
Depends on: 1368605
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: