Binary data and HAR files

1,060 views
Skip to first unread message

Paul

unread,
Nov 2, 2014, 4:03:35 PM11/2/14
to fir...@googlegroups.com
Hi,

Can a combination of Firebug and NetExport be used to save binary data in a HAR file?

I am not familiar with the source code of either so I could be heading in the wrong direction, but I have taken a look, and the following code seems to try and convert every response into Unicode.

https://github.com/firebug/firebug/blob/58c5de64c21759dc66d3d762c45942a3448cb2be/extension/content/firebug/net/tabCache.js#L336

Is this correct for non-text data?

Using this PNG file, http://upload.wikimedia.org/wikipedia/commons/thumb/7/76/Mozilla_Firefox_logo_2013.svg/40px-Mozilla_Firefox_logo_2013.svg.png, in the following HTML:

<!doctype html>

<body>

<img src="Mozilla_Firefox_logo_2013.svg.png">

</body>


the response gets converted and I can't seem to get the original image data back.

I have attached a HAR as an example.

The first 4 bytes of a PNG should be [0x89, 'P', 'N', 'G'], or [89 50 4E 47], but the exported HAR has content "‰PNG" in the HAR file, which is [E2 80 B0 50 4E 47].  I have not been able to transform this encoded string representation back to the original bytes.  Maybe an encoding issue?

It seems as though 0x89 in Windows CP1252 is the same double-percent character, so could this have something to do with it?  In which case, do I need to know the platform's default encoding to map UTF8 characters back to platform encoded characters in order to retrieve the image data? (http://effbot.org/zone/unicode-gremlins.htm)

Chrome seems to use base64 to export the same image when saving as HAR from Chrome.  Would this be a safer option all round?

Thanks for any help,

Paul.

localhost-8080.har

Paul

unread,
Nov 2, 2014, 6:09:59 PM11/2/14
to fir...@googlegroups.com
Update, in case this helps.

If I decode the responseText from the HAR file as Windows-1252 then I successfully get the PNG file header.

But I then get a difference at byte 340.  0x8D in the original image is mapped to 0x3F, which is QUESTION MARK, and I think this char is used (in Java - I'm using Java to decode) for mapping invalid byte sequences with respect to a particular encoding.
Reply all
Reply to author
Forward
0 new messages