GoogleCloudPlatform / webapp2

webapp2 is a framework for Google App Engine
https://webapp2.readthedocs.org
Other
142 stars 64 forks source link

Performing self.redirect(abort=True) ignores cookies (and other response properties) #111

Closed mikelambert closed 8 years ago

mikelambert commented 8 years ago

Normally I can call self.response.set_cookie(), and then call self.redirect(new_url), and the cookies will be sent along with the redirect. However, if I call self.redirect(new_url, abort=True), it ignores the cookies entirely. I've run into this multiple times over the years as I forget the lesson due to how non-obvious the behavior is.

I believe the problem is due to the call to: _abort(code, headers=[('Location', uri)]). Perhaps it should be grabbing and including more headers from the passed-in self.response instead of passing just the Location?

theacodes commented 8 years ago

Probably. Happy to review any pull request if you want to contribute a fix for it.

mikelambert commented 8 years ago

I can write a pull request, as long as you're okay with the fact that it'll be completely untested in prod GAE/GCE environment. (Though I should be able to test in a dev appserver, at least.)

theacodes commented 8 years ago

Yep, that's fine. We have travis setup on this repo and I have an outstanding issue to do prod tests before publishing a new release.