Skip to content

.reload() fails if the previous request was a POST #74

@mgedmin

Description

@mgedmin

I've seen variations on this, some of which end up in an error like

Failed example:
    manager.reload()
Exception raised:
    Traceback (most recent call last):
      File "/usr/lib/python2.7/doctest.py", line 1315, in __run
        compileflags, 1) in test.globs
      File "<doctest invitations.txt[101]>", line 1, in <module>
        manager.reload()
      File "/home/mg/src/zopefoundation/zope.testbrowser/src/zope/testbrowser/browser.py", line 197, in reload
        resp = self.testapp.request(req)
      File "/home/mg/src/ivija/.tox/py27-latest/local/lib/python2.7/site-packages/webtest/app.py", line 581, in request
        req = url_or_req.copy()
      File "/home/mg/src/ivija/.tox/py27-latest/local/lib/python2.7/site-packages/webob/request.py", line 861, in copy
        self.make_body_seekable()
      File "/home/mg/src/ivija/.tox/py27-latest/local/lib/python2.7/site-packages/webob/request.py", line 929, in make_body_seekable
        self.copy_body()
      File "/home/mg/src/ivija/.tox/py27-latest/local/lib/python2.7/site-packages/webob/request.py", line 953, in copy_body
        data = input.read(min(todo, 65535))
      File "/home/mg/src/ivija/.tox/py27-latest/local/lib/python2.7/site-packages/webob/request.py", line 1544, in readinto
        "(%d more bytes were expected)" % (self.remaining,)
    DisconnectionError: The client disconnected while sending the body (79 more bytes were expected)

and some of which silently end up with a browser.contents of ''. (that was actually a different bug, see #75)

I get the impression that submitting a form and then calling reload() in the old mechanize-based testbrowser used to replay the last POST request as a GET to the same URL.

I don't think that's a good idea either, so what I propose instead is to have zope.testbrowser explicitly raise a BrowserStateError() if you try to reload a POST.

Metadata

Metadata

Assignees

No one assigned

    Labels

    compatCompatibility issues due to mechanize -> webtest migration in 5.0.0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions