Anonymous avatar Anonymous committed 22a7d99

Added follow_redirect to the werkzeug.test.Client for easier testing.

Comments (0)

Files changed (15)

Add a comment to this file

examples/cupoftee/shared/down.png

Old
Old image
New
New image
Add a comment to this file

examples/cupoftee/shared/up.png

Old
Old image
New
New image
Add a comment to this file

examples/manage-coolmagic.py

File contents unchanged.

Add a comment to this file

examples/manage-couchy.py

File contents unchanged.

Add a comment to this file

examples/manage-cupoftee.py

File contents unchanged.

Add a comment to this file

examples/manage-i18nurls.py

File contents unchanged.

Add a comment to this file

examples/manage-plnt.py

File contents unchanged.

Add a comment to this file

examples/manage-shorty.py

File contents unchanged.

Add a comment to this file

examples/manage-simplewiki.py

File contents unchanged.

Add a comment to this file

examples/manage-webpylike.py

File contents unchanged.

Add a comment to this file

werkzeug/debug/shared/console.png

Old
Old image
New
New image
Add a comment to this file

werkzeug/debug/shared/less.png

Old
Old image
New
New image
Add a comment to this file

werkzeug/debug/shared/more.png

Old
Old image
New
New image
Add a comment to this file

werkzeug/debug/shared/source.png

Old
Old image
New
New image
         Additional parameters:
 
         :param as_tuple: Returns a tuple in the form ``(environ, result)``
-        :param buffered: set this to true to buffer the application run.
+        :param buffered: Set this to true to buffer the application run.
                          This will automatically close the application for
                          you as well.
+        :param follow_redirects: Set this to false if the `Client` should not
+                                 follow http redirects.
         """
         as_tuple = kwargs.pop('as_tuple', False)
         buffered = kwargs.pop('buffered', False)
+        follow_redirects = kwargs.pop('follow_redirects', True)
         environ = None
         if not kwargs and len(args) == 1:
             if isinstance(args[0], EnvironBuilder):
         rv = run_wsgi_app(self.application, environ, buffered=buffered)
         if self.cookie_jar is not None:
             self.cookie_jar.extract_wsgi(environ, rv[2])
+
+        if rv[0].status_code in (301, 302, 303, 305, 307) and follow_redirects:
+            redirect = urlparse.urlunsplit(urlparse.urlsplit(
+                dict(rv[2])['Location'])[:-2] + ('', ''))
+            kwargs.update({
+                'base_url': redirect,
+                'as_tuple': as_tuple,
+                'buffered': buffered,
+                'follow_redirects': follow_redirects,
+            })
+            return self.open(*args, **kwargs)
+
         response = self.response_wrapper(*rv)
         if as_tuple:
             return environ, response
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.