-
Notifications
You must be signed in to change notification settings - Fork 247
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
HAR PostData text is wrong type #245
Comments
I'm happy to provide a PR if you're OK with this (it is a breaking change). |
Ah good catch - yep I'd be happy to take a PR! Please add a test to cover
this behavior as well.
Much appreciated!
Bramha
…On Fri, May 25, 2018, 10:52 AM Jonathan Amsterdam ***@***.***> wrote:
I'm happy to provide a PR if you're OK with this (it is a breaking change).
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#245 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AADI-QO3kJfapyiyIqZD0pO-dRcwcDgYks5t2ETRgaJpZM4UOWwe>
.
|
jba
added a commit
that referenced
this issue
May 26, 2018
Previously, it was string, which doesn't correctly round-trip with encoding/json because that package requires strings to be valid UTF-8. The right type is []byte, since post data can be arbitrary bytes. Fixes #245.
jba
added a commit
that referenced
this issue
May 30, 2018
Previously, post data did not round-trip with encoding/json because that package requires strings to be valid UTF-8, and post data can be arbitrary bytes. Following the suggestion in https://groups.google.com/forum/#!topic/http-archive-specification/9wYrqin3Fsc/discussion, binary (that is, invalid UTF-8) post data is implemented by base64-encoding the data in the "text" key, and adding an "encoding" key equal to "base64". Fixes #245.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
har.PostData.Text
, the body of a POST, has typestring
. This is a mistake. It should be[]byte
.The HAR spec does say that
text
is a string, but it means a JSON string, not a Go string. POST data can contain arbitrary bytes (e.g. if the MIME type is application/octet-stream).The reason this matters is that
encoding/json.Marshal
expects strings to be valid UTF-8; if they are not, it loses information by replacing invalid code points with the replacement character. So when ahar.Log
is marshaled to JSON, the result is wrong.Example:
Output:
The text was updated successfully, but these errors were encountered: