New issue
Advanced search Search tips

Issue 778286 link

Starred by 2 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Dec 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows , Mac
Pri: 2
Type: Bug



Sign in to add a comment

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:
 

Comment 1 by br...@dockyard.com, Oct 25 2017

This 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
Components: Internals>Headless

Comment 3 by lgrey@chromium.org, Oct 26 2017

Labels: Proj-Headless
Components: Platform>DevTools
Labels: OS-Windows
Status: Available (was: Unconfirmed)
This seems to be intentional (?): https://cs.chromium.org/chromium/src/content/browser/devtools/devtools_http_handler.cc?rcl=8b7d48f1c59bcc8258556e6e71cb6f4084ddbac2&l=586
Status: WontFix (was: Available)
Existing clients already rely upon this behavior.

Comment 6 by br...@dockyard.com, 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` ?
@brian: what is your use case? Did you consider using Target domain?

Comment 8 by br...@dockyard.com, 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.

Comment 9 by br...@dockyard.com, Dec 23 2017

@pfeldman ping on my last comment
@brian: still waiting for your comment on #7.

Comment 11 by br...@dockyard.com, Dec 28 2017

@pfeldman did you see the use case in #8 or are you referring to the Target domain?
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