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

Add test_httpbin_accepts_lots_of_get_requests_in_single_session #13

Conversation

msabramo
Copy link
Collaborator

@msabramo msabramo commented Dec 1, 2014

This test is actually failing for me at least part of the time on py34.

This was inspired by a bug in httpie:
httpie/cli#278 (comment)

This test is actually failing for me at least part of the time on py34.

This was inspired by a bug in httpie:
httpie/cli#278 (comment)
@msabramo
Copy link
Collaborator Author

msabramo commented Dec 1, 2014

Notice test fails on py33 with:

=================================== FAILURES ===================================
_________ test_httpbin_accepts_lots_of_get_requests_in_single_session __________
...
        except (ProtocolError, socket.error) as err:
>           raise ConnectionError(err, request=request)
E           requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine("''",))
../../../virtualenv/python3.4.2/lib/python3.4/site-packages/requests/adapters.py:407: ConnectionError
----------------------------- Captured stderr call -----------------------------
127.0.0.1 - - [01/Dec/2014 01:51:59] "GET /get HTTP/1.1" 200 332
===================== 1 failed, 13 passed in 1.35 seconds ======================

@msabramo
Copy link
Collaborator Author

msabramo commented Dec 1, 2014

Fails locally too:

❯ .tox/py33/bin/py.test --tb=short -k test_httpbin_accepts_lots_of_get_requests_in_single_session --pdb
============================================================================= test session starts ==============================================================================
platform darwin -- Python 3.3.3 -- py-1.4.26 -- pytest-2.6.4
plugins: httpbin
collected 14 items

tests/test_httpbin.py F
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> traceback >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
tests/test_httpbin.py:27: in test_httpbin_accepts_lots_of_get_requests_in_single_session
    assert session.get(httpbin.url + '/get').status_code == 200
.tox/py33/lib/python3.3/site-packages/requests/sessions.py:469: in get
    return self.request('GET', url, **kwargs)
.tox/py33/lib/python3.3/site-packages/requests/sessions.py:457: in request
    resp = self.send(prep, **send_kwargs)
.tox/py33/lib/python3.3/site-packages/requests/sessions.py:569: in send
    r = adapter.send(request, **kwargs)
.tox/py33/lib/python3.3/site-packages/requests/adapters.py:407: in send
    raise ConnectionError(err, request=request)
E   requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine("''",))
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> entering PDB >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> /Users/marca/dev/git-repos/pytest-httpbin/.tox/py33/lib/python3.3/site-packages/requests/adapters.py(407)send()
-> raise ConnectionError(err, request=request)

@msabramo
Copy link
Collaborator Author

msabramo commented Dec 1, 2014

I feel like this has something to do with the fact that wsgiref is being used for HTTP/1.1. If I changed http_version to 1.0 then this test always passes.

I'm guessing it has something to do with HTTP/1.1 defaulting to using keep alives rather than closing the connection like in HTTP/1.0.

msabramo added a commit to msabramo/pytest-httpbin that referenced this pull request Dec 1, 2014
that adds `Connection: Close` response header so that clients don't
expect keep alives.

Fixes: kevin1024#13
@msabramo
Copy link
Collaborator Author

msabramo commented Dec 1, 2014

PR #16 appears to fix this issue for me.

$ tox
...
  py26: commands succeeded
  py27: commands succeeded
  py34: commands succeeded
  pypy: commands succeeded
  congratulations :)

@sigmavirus24
Copy link

Perhaps this should be closed since the commit is in #16

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.

3 participants