-
-
Notifications
You must be signed in to change notification settings - Fork 426
No response headers when body is empty and status code is not 200 #359
Comments
This is sort of complicated, but I think your application is actually returning a response code of 0. The default setting for the Rails test environment is to raise exceptions instead of rescuing and displaying them (this is the There's been some work in capybara (teamcapybara/capybara#660) to improve this situation. For now, I'd recommend turning |
Thanks for the reply, but have you looked at the code I submitted? There are no exceptions involved. The status code 404 is generated by me, manually. It could be some other code, like 403. Also, when tested in a real browser, things work as they should and you get the 403/404 or whatever status that was generated. Finally, nothing in your explanation addresses why there is a difference between an empty body and a non empty one. |
@marcandre sorry, I missed that. I'll try to reproduce this when I can. If you get a chance to put together a failing test, that would help speed things up. |
There is a failing test at the end... |
@marcandre sorry - to be clear, I meant a failing spec in capybara-webkit. |
Hmmm, I don't have the time, and it should be much easier for someone who knows the codebase, based on my very simple example. |
We've long since reworked our connection handling code. Headers and status codes are handled completely differently, resolving this issue. Please reopen if you're still having issues in the latest version. |
Still happening with * capybara-webkit (1.7.1) Resolved with render json: { blacklisted: true }, status: :unprocessable_entity instead of head :unprocessable_entity in my controller |
@delphaber is there a minimal test case you could put together to reproduce the issue? |
If a request returns a non-200, empty response, the XHR object will have a status of 0 with no headers. Status: failing test Reproduces issue reported in #359.
I managed to put together a failing test in d6c72bc that reproduces the issue. I'm not sure if this is an issue in QtWebKit or related to how we handle requests. |
I love this; we're running into the same problem but with redirects. Would be great to get this resolved. |
Still affected on Capybara 2.17.0, but I'm not using capybara-webkit. Is this a Capybara issue? |
@mdesantis It's an issue with whatever driver you are using. If you're not using capybara-webkit then I'm guessing Poltergeist since PhantomJS (used by poltergeist) is built on the same era of QtWebkit as capybara-webkit builds against. |
If an Ajax request is made and the response has:
Then the request headers in javascript are empty and the status code is 0.
If the body contains something (e.g. a single character) or the status code is 200, then things work as they should.
To reproduce:
The test fails with:
Response will vary, but notice the "0|" which indicated a status code of 0 (instead of 404) and no headers whatsoever.
The text shows correctly in Chrome, Firefox and Safari.
Using capybara-webkit (0.12.1) on OS X
The text was updated successfully, but these errors were encountered: