class HostRequestMatcher : WebRequestMatcher
A WebRequestMatcher that allows matching on the host and optionally the port of WebRequest#getUrl()
.
For example, the following would match any request to the host "code.jquery.com"
without regard for the port.
WebRequestMatcher cdnMatcher = new HostMatcher("code.jquery.com");
Multiple hosts can also be passed in. For example, the following would match any request to the host "code.jquery.com"
or the host "cdn.com"
without regard for the port.
WebRequestMatcher cdnMatcher = new HostMatcher("code.jquery.com", "cdn.com");
Alternatively, one can also specify the port. For example, the following would match any request to the host "code.jquery.com"
with the port of 80
.
WebRequestMatcher cdnMatcher = new HostMatcher("code.jquery.com:80");
The above cdnMatcher
would match "http://code.jquery.com/jquery.js"
which has a default port of 80
and "http://code.jquery.com:80/jquery.js"
. However, it would not match "https://code.jquery.com/jquery.js"
which has a default port of 443
.
Author
Rob Winch
Author
Sam Brannen
Since
4.2
See Also
UrlRegexRequestMatcherorg.springframework.test.web.servlet.htmlunit.DelegatingWebConnection
HostRequestMatcher(vararg hosts: String)
Create a new |
fun matches(request: WebRequest): Boolean |