When closing a tab via Headless API the response body is not JSON as the response header indicated
Reported by
br...@dockyard.com,
Oct 25 2017
|
|||||
Issue description
UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.62 Safari/537.36
Steps to reproduce the problem:
1. Close a tab via Headless API
2. Inspect response
3.
What is the expected behavior?
The response header content-type is "application/json" but the body itself is just plain text and not JSON
What went wrong?
I would expect either the content-type to be changed to "text/plain" or the body to be a json payload: "{message: 'Tab is closing'}"
Did this work before? N/A
Does this work in other browsers? N/A
Chrome version: 62.0.3202.62 Channel: stable
OS Version: OS X 10.12.6
Flash Version:
,
Oct 25 2017
,
Oct 26 2017
,
Oct 27 2017
This seems to be intentional (?): https://cs.chromium.org/chromium/src/content/browser/devtools/devtools_http_handler.cc?rcl=8b7d48f1c59bcc8258556e6e71cb6f4084ddbac2&l=586
,
Dec 11 2017
Existing clients already rely upon this behavior.
,
Dec 11 2017
@pfeldman this doesn't seem like a great reason. At the very least can the response type be changed to `text/plain` ?
,
Dec 11 2017
@brian: what is your use case? Did you consider using Target domain?
,
Dec 11 2017
There are many http libraries that will deserialize data based upon the content type. In these cases you have to capture the error state and handle it, which depending upon the language is not very performant.
,
Dec 23 2017
@pfeldman ping on my last comment
,
Dec 27 2017
@brian: still waiting for your comment on #7.
,
Dec 28 2017
@pfeldman did you see the use case in #8 or are you referring to the Target domain?
,
Dec 28 2017
I don't think I did see the use case. Probably some libraries deserialize data, but others don't. "which depending upon the language is not very performant" does not sound real provided we are talking about anr http request here. |
|||||
►
Sign in to add a comment |
|||||
Comment 1 by br...@dockyard.com
, Oct 25 2017This could also be as simple as ensuring the resulting body is wrapped in quotes: JSON.parse('Target is closing') => SyntaxError JSON.parse('"Target is closing"') => "Target is closing" Ensuring the wrapping quotes are part of the body would be valid JSON