SpringSource/spring-framework — pull request #108 by rwinch (2012-07-13 21:48:53+00:00)
Title: Fix minor issue in MockHttpServletRequest

# A few points of discussion:

* This changes the behavior of getRedirectedUrl since if someone adds the Location header it is now updated. I think this is correct behavior but it could be preferable to do this in another JIRA. I did it in this one because I thought it was weird keeping the state in two distinct locations. Please let me know if you would like this changed.
* [SPR-9594](https://jira.springsource.org/browse/SPR-9594) points out the spec states "Sends a temporary redirect response ..." Interestingly enough there is a constant named [SC_TEMPORARY_REDIRECT](http://docs.oracle.com/cd/E17802_01/products/products/servlet/2.3/javadoc/javax/servlet/http/HttpServletResponse.html#SC_TEMPORARY_REDIRECT) that is equal to 307 (not 302 as we believe the status should be). I still think 302 is the correct status, but thought I would point this out. There are two constants for a 302 ([SC_MOVED_TEMPORARILY](http://docs.oracle.com/cd/E17802_01/products/products/servlet/2.3/javadoc/javax/servlet/http/HttpServletResponse.html#SC_MOVED_TEMPORARILY) and [SC_FOUND](http://tomcat.apache.org/tomcat-5.5-doc/servletapi/javax/servlet/http/HttpServletResponse.html#SC_FOUND)) that have documentation stating it should be used for temporarily moved. The reason I brought up SC_TEMPORARY_REDIRECT is that it is an exact match of the spec.

# Changes

Previously MockHttpServletRequest#sendRedirect did not set the HTTP status
or the Location header. This does not conform to the HttpServletRequest
interface.

MockHttpServletRequest will now:

- Set the HTTP status to 302 on sendRedirect
- Set the Location header on sendRedirect
- Ensure the Location header and getRedirectedUrl are kept in synch

Issue: SPR-9594