类 HeaderAssertions
- java.lang.Object
- org.springframework.test.web.reactive.server.HeaderAssertions
public class HeaderAssertions extends Object
Assertions on headers of the response.- 从以下版本开始:
- 5.0
- 作者:
- Rossen Stoyanchev, Brian Clozel, Sam Brannen
- 另请参阅:
WebTestClient.ResponseSpec.expectHeader()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 WebTestClient.ResponseSpec
cacheControl(CacheControl cacheControl)
Expect a "Cache-Control" header with the given value.WebTestClient.ResponseSpec
contentDisposition(ContentDisposition contentDisposition)
Expect a "Content-Disposition" header with the given value.WebTestClient.ResponseSpec
contentLength(long contentLength)
Expect a "Content-Length" header with the given value.WebTestClient.ResponseSpec
contentType(String mediaType)
Expect a "Content-Type" header with the given value.WebTestClient.ResponseSpec
contentType(MediaType mediaType)
Expect a "Content-Type" header with the given value.WebTestClient.ResponseSpec
contentTypeCompatibleWith(String mediaType)
Expect a "Content-Type" header compatible with the given value.WebTestClient.ResponseSpec
contentTypeCompatibleWith(MediaType mediaType)
Expect a "Content-Type" header compatible with the given value.WebTestClient.ResponseSpec
doesNotExist(String name)
Expect that the header with the given name is not present.WebTestClient.ResponseSpec
exists(String name)
Expect that the header with the given name is present.WebTestClient.ResponseSpec
expires(long expires)
Expect an "Expires" header with the given value.WebTestClient.ResponseSpec
lastModified(long lastModified)
Expect a "Last-Modified" header with the given value.WebTestClient.ResponseSpec
value(String name, Consumer<String> consumer)
Consume the first value of the response header.WebTestClient.ResponseSpec
value(String name, Matcher<? super String> matcher)
Assert the first value of the response header with a HamcrestMatcher
.WebTestClient.ResponseSpec
valueEquals(String headerName, String... values)
Expect a header with the given name to match the specified values.WebTestClient.ResponseSpec
valueMatches(String name, String pattern)
Match the first value of the response header with a regex.
方法详细资料
valueEquals
public WebTestClient.ResponseSpec valueEquals(String headerName, String... values)
Expect a header with the given name to match the specified values.
valueMatches
public WebTestClient.ResponseSpec valueMatches(String name, String pattern)
Match the first value of the response header with a regex.- 参数:
name
- the header namepattern
- the regex pattern
value
public WebTestClient.ResponseSpec value(String name, Matcher<? super String> matcher)
Assert the first value of the response header with a HamcrestMatcher
.- 参数:
name
- the header namematcher
- the matcher to use- 从以下版本开始:
- 5.1
value
public WebTestClient.ResponseSpec value(String name, Consumer<String> consumer)
Consume the first value of the response header.- 参数:
name
- the header nameconsumer
- the consumer to use- 从以下版本开始:
- 5.1
exists
public WebTestClient.ResponseSpec exists(String name)
Expect that the header with the given name is present.- 从以下版本开始:
- 5.0.3
doesNotExist
public WebTestClient.ResponseSpec doesNotExist(String name)
Expect that the header with the given name is not present.
cacheControl
public WebTestClient.ResponseSpec cacheControl(CacheControl cacheControl)
Expect a "Cache-Control" header with the given value.
contentDisposition
public WebTestClient.ResponseSpec contentDisposition(ContentDisposition contentDisposition)
Expect a "Content-Disposition" header with the given value.
contentLength
public WebTestClient.ResponseSpec contentLength(long contentLength)
Expect a "Content-Length" header with the given value.
contentType
public WebTestClient.ResponseSpec contentType(MediaType mediaType)
Expect a "Content-Type" header with the given value.
contentType
public WebTestClient.ResponseSpec contentType(String mediaType)
Expect a "Content-Type" header with the given value.
contentTypeCompatibleWith
public WebTestClient.ResponseSpec contentTypeCompatibleWith(MediaType mediaType)
Expect a "Content-Type" header compatible with the given value.
contentTypeCompatibleWith
public WebTestClient.ResponseSpec contentTypeCompatibleWith(String mediaType)
Expect a "Content-Type" header compatible with the given value.
expires
public WebTestClient.ResponseSpec expires(long expires)
Expect an "Expires" header with the given value.
lastModified
public WebTestClient.ResponseSpec lastModified(long lastModified)
Expect a "Last-Modified" header with the given value.