Closed Bug 1221754 Opened 9 years ago Closed 9 years ago

HAR fails to specify encoding for base64-encoded resources

Categories

(DevTools :: Netmonitor, defect)

45 Branch
defect
Not set
normal

Tracking

(firefox45 fixed)

RESOLVED FIXED
Firefox 45
Tracking Status
firefox45 --- fixed

People

(Reporter: ericlaw1979, Assigned: Honza)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0
Build ID: 20151104030437

Steps to reproduce:

1. Open the Developer Tools, Network Tool.
2. Visit any page with binary resources (or directly navigate to a binary resource like this image: https://www.bayden.com/images/banner.jpg?12345)
3. Right click in the Network Request list and choose "Copy all as HAR"




Actual results:

HAR text is copied to the clipboard, and the resource is base64 encoded:

    "content": {
            "mimeType": "image/jpeg",
            "size": 6171,
            "text": "/9j/4AAQSkZJRgD...VKgD//Z"
          }

... however the "encoding" attribute indicating that this encoding was performed is missing from the JSON.



Expected results:


Specifically, the JSON should look like this:

    "content": {
            "mimeType": "image/jpeg",
            "size": 6171,
            "text": "/9j/4AAQSkZJRgD...VKgD//Z",
            "encoding": "base64"
          },

From the HAR spec:

text [string, optional] - Response body sent from the server or loaded from the browser cache. This field is populated with textual content only. The text field is either HTTP decoded text or a encoded (e.g. "base64") representation of the response body. Leave out this field if the information is not available.

encoding [string, optional] (new in 1.2) - Encoding used for response text field e.g "base64".

This bug should be linked to https://bugzilla.mozilla.org/show_bug.cgi?id=859058
Honza, this looks like an easy fix.  Would you like to do it, or maybe mentor someone else to do so?
Component: General → Developer Tools: Netmonitor
Flags: needinfo?(odvarko)
The attached patch exports also encoding.

Eric, thanks for the report!


Honza
Assignee: nobody → odvarko
Status: NEW → ASSIGNED
Flags: needinfo?(odvarko)
Attachment #8684881 - Flags: review?(jryans)
Comment on attachment 8684881 [details] [diff] [review]
bug1221754-1.patch

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

In general this looks fine, but I recall :tromey recently removed encoding somewhere, so let's have him take a look too.
Attachment #8684881 - Flags: review?(ttromey)
Attachment #8684881 - Flags: review?(jryans)
Attachment #8684881 - Flags: review+
Comment on attachment 8684881 [details] [diff] [review]
bug1221754-1.patch

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

Looks good.
Attachment #8684881 - Flags: review?(ttromey) → review+
From IRC discussion, it sounds like there may be more details to resolve here before landing.
Yep, I am working it.

Honz
I double checked and the patch works correctly.

I wasn't clear on IRC, here are corrected notes:

1) 'response.content.encoding' - specified encoding used for response.content.text field (e.g "base64"). This has nothing to do with encoding in HTTP, it only says how the response content is encoded in the HAR file.
2) 'response.content.size' - length of the returned content in bytes. Should be equal to response.bodySize if there is no compression and bigger when the content has been compressed.
3) 'response.bodySize' - Size of the received response body in bytes. Should zero in case of responses coming from the cache (304). Should be -1 if the info is not available.


Tom's patch in bug 937586 is just fine and making things better.


Add #3 was -1 even for 304 requests, it's fixed by the (second) attached patch. But, let me know if I should report another bug for this.

Honza
Attachment #8686015 - Flags: review?(jryans)
https://hg.mozilla.org/mozilla-central/rev/0788d3d50016
https://hg.mozilla.org/mozilla-central/rev/69777d636519
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 45
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: