Skip to content
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

Default celerity to set accept header to "text/html" rather than "*/*" and add override mechanism. #49

Merged

Conversation

wolframarnold
Copy link
Contributor

HTMLUnit sends the first request to a server with accept header set to "/". This causes some servers to not respond with HTML and is probably not what's intended. For a more detailed discussion, see here: http://stackoverflow.com/questions/4824028/celerity-cannot-follow-a-devise-redirect-because-celerity-doesnt-send-an-accept

I've added the ability to set the accept header explicitly in the Browser#goto method. If it's not set, it'll default to "text/html" rather than "/". This change was TDD's and tests are included.

…ers. If no accept header is set, default it to 'text/html'.

Some web servers don't respond with HTML if they get an accept header of "*/*" which was the previous behavior.
@jarib
Copy link
Owner

jarib commented Feb 3, 2011

HtmlUnit should ideally match the Accept header used by the browser being emulated (as specified through the :browser constructor option in Celerity / BrowserVersion in HtmlUnit). I'd prefer if you raised a bug with them about this, and changed the patch to not modify the headers unless the user explicitly passes in the headers hash.

Thanks!

@jarib
Copy link
Owner

jarib commented Feb 3, 2011

Firefox defaults to:

text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

and Chromium to

application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5

@jarib
Copy link
Owner

jarib commented Mar 28, 2011

I'm about to release 0.8.9, please address my previous comment if you want to get this in.

@wolframarnold
Copy link
Contributor Author

Hi, Jari,

Thanks for the shout-out. I've not had time to fix this. I have raised it with the HTMLUnit guys and filed a bug report there. I agree with your suggestion to leave the default behavior as is and override as needed, but I've not had the bandwidth to pick this back up.

In my application I've worked around the issue with a small rack middleware patch that sets the accept header explicitly if it's missing.

Don't let this hold up your release, and thanks for checking back.

Wolf

@jarib
Copy link
Owner

jarib commented Mar 28, 2011

Thanks for the quick reply - I'll pull it in and fix that one line myself :)

@jarib jarib merged commit cba38c8 into jarib:master Mar 28, 2011
@wolframarnold
Copy link
Contributor Author

Thanks you're the best!
On Mar 28, 2011 4:51 PM, "jarib" <
reply@reply.github.com>
wrote:

Thanks for the quick reply - I'll pull it in and fix that one line myself
:)

Reply to this email directly or view it on GitHub:
#49 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants