title: response.sendRedirect shows unwanted HttpStatus 302 instead of 307
body: <p>I have a small test, which should return a HttpStatus with Temporary Redirect with HttpStatus Code 307.<br>
  But it always returns a 302.  </p>
  
  <pre><code>@RestController
  @RequestMapping(value = "/")
  public class Controller {
  
      @ResponseStatus(HttpStatus.TEMPORARY_REDIRECT ) 
      @RequestMapping(value= "test", method = RequestMethod.GET)
      public void resolveUrl(HttpServletResponse response) throws IOException {
          response.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT);
          response.sendRedirect("https://www.google.com");
      }
  }
  </code></pre>
  
  <p>When I look into the documentation of <code>response.sendRedirect()</code> I can read this: </p>
  
  <blockquote>
    <p>Sends a temporary redirect response to the client using the specified
         * redirect location URL.</p>
  </blockquote>
  
  <p>and the <a href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html" rel="nofollow noreferrer">documentation of temporary redirect is a 307</a>:</p>
  
  <blockquote>
    <p>10.3.8 307 Temporary Redirect</p>
    
    <p>The requested resource resides temporarily under a different URI.
    Since the redirection MAY be altered on occasion, the client SHOULD
    continue to use the Request-URI for future requests. This response is
    only cacheable if indicated by a Cache-Control or Expires header
    field.</p>
  </blockquote>
  
  <p>(I know, that I don't need the <code>@ResponseStatus(HttpStatus.TEMPORARY_REDIRECT)</code> or the <code>response.setStatus(HttpServletResponse.SC_TEMPORARY_REDIRECT);</code> but I want to show that it will not work with this things too!)</p>
  
  <p>But my test shows that it was a 302 and not a 307</p>
  
  <blockquote>
    <p>java.lang.AssertionError: Status expected:&lt;307> but was:&lt;302></p>
  </blockquote>
  
  <p>Can somebody explain this?</p>
  
  <p>My small test for this:</p>
  
  <pre><code>@RunWith(SpringRunner.class)
  @WebMvcTest(Controller.class)
  public class ControllerTest {
  
      @Autowired
      private MockMvc mvc;
  
      @Test
      public void test() throws Exception {
          MockHttpServletRequestBuilder requestBuilder = get("/test");
          mvc.perform(requestBuilder).andExpect(status().isTemporaryRedirect())
                  .andExpect(redirectedUrl("https://www.google.com"));
      }
  
  }
  </code></pre>
  
  <p><a href="https://github.com/joergi/temporalymoved" rel="nofollow noreferrer">Complete code can be found at github</a></p>