Copy cookies and hints in built ServerResponse

Closes gh-22481
This commit is contained in:
Arjen Poutsma
2019-03-26 15:31:15 +01:00
parent fd6b64bfac
commit d8215e7c79
4 changed files with 32 additions and 17 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -65,11 +65,17 @@ public class DefaultServerResponseBuilderTests {
@Test
public void from() {
ServerResponse other = ServerResponse.ok().header("foo", "bar").build().block();
ResponseCookie cookie = ResponseCookie.from("foo", "bar").build();
ServerResponse other = ServerResponse.ok().header("foo", "bar")
.cookie(cookie)
.hint("foo", "bar")
.build().block();
Mono<ServerResponse> result = ServerResponse.from(other).build();
StepVerifier.create(result)
.expectNextMatches(response -> HttpStatus.OK.equals(response.statusCode()) &&
"bar".equals(response.headers().getFirst("foo")))
"bar".equals(response.headers().getFirst("foo")) &&
cookie.equals(response.cookies().getFirst("foo")))
.expectComplete()
.verify();
}