Skip to content
This repository was archived by the owner on May 30, 2023. It is now read-only.

Default WebKit Accept header causes problems with some web services/servers #10112

Closed
ariya opened this issue May 27, 2011 · 2 comments
Closed

Comments

@ariya
Copy link
Owner

ariya commented May 27, 2011

timfar...@gmail.com commented:

What steps will reproduce the problem?

  1. Run the following script:

if (phantom.state.length == 0) {
phantom.state = '1';
phantom.open( 'http://gdata.youtube.com/feeds/api/videos?author=geologicrecords&v=2&prettyprint=true&start-index=1&max-results=5' );
} else {
console.log( phantom.content );
phantom.exit();
}

  1. Fetch the same URL using another tool such as WGET or a recent build of Firefox to see correct results.

What is the expected output? What do you see instead?
Should show a pretty-printed ATOM feed of the data about 5 videos on YouTube. Instead, the data is all HTML-escaped for literal display and is surrounded by <html> and <body> tags.

What version of the product are you using? On what operating system?
PhantomJS 1.1 Mac OS/X 10.6.7

Please provide any additional information below.
I was able to isolate the problem to the Accept: header being sent by WebKit. If you Google WebKit Accept header you will see there has been considerable complaints that WebKit is using a bad default, taken from an old build of Firefox. WGET works correctly because it sends Accept: /.

WebKit is prioritizing text/plain too high (and making other errors), so in this case Google's servers sends the result back as "text/plain" and WebKit tries to escape it for easy display.

At the very least, we should update the default for the Accept: header that is used by default in PhantomJS. If <a href="http://code.google.com/p/phantomjs/issues/detail?id=77&quot;&gt;Issue 77</a> is resolved in a way that allows setting the Accept: header, it should fix this bug as well. (But I think it would be best to change the default as well).

Disclaimer:
This issue was migrated on 2013-03-15 from the project's former issue tracker on Google Code, Issue #112.
🌟   2 people had starred this issue at the time of migration.

@ariya
Copy link
Owner Author

ariya commented Jun 8, 2011

roejame...@gmail.com commented:

In the meantime, if you need the problem fixed asap, try exploiting the bug in comment #5.
http://code.google.com/p/phantomjs/issues/detail?id=45#c5

@zackw
Copy link
Contributor

zackw commented Apr 19, 2015

PhantomJS 2.0's Accept: header for top-level documents is consistent with that generated by Chromium and Firefox.

@zackw zackw closed this as completed Apr 19, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants