如何放心重新导向?

bri*_*661 3 rest-assured

我有一个spring boot应用程序,控制器将根据post参数重定向到页面。
我正在创建要断言重定向页面的测试用例,但是我无法从放心的响应中获取重定向的html

    @Test
    public void test() throws Exception {

        Response response = given()
            .param("name", "myName")
        .when()
            .redirects().follow(true).redirects().max(100)
            .post("/myPath");      // it will redirect to another page


        // I want to print from <html> to </html> of the redirected page
        System.out.println("returned full html /n" + response.getBody().asString());  
    }
Run Code Online (Sandbox Code Playgroud)

我收到302以及重定向页在响应标头中的位置。

11:38:03.291 [main] DEBUG org.apache.http.headers - << "Location: http://localhost:8080/myRedirectPage[\r][\n]"
.........
11:38:03.291 [main] DEBUG org.apache.http.impl.conn.DefaultClientConnection - Receiving response: HTTP/1.1 302 
11:38:03.291 [main] DEBUG org.apache.http.headers - << HTTP/1.1 302 
Run Code Online (Sandbox Code Playgroud)

Man*_*amy 5

我有类似的问题,为了确保重定向,不支持使用状态代码302和307的“发布”。我们必须使用303状态代码将其更改为“ get”或“ post”。更多信息请点击这里