MockHttpServletRequestBuilder.java (spring-framework-5.3.23) | : | MockHttpServletRequestBuilder.java (spring-framework-5.3.24) | ||
---|---|---|---|---|
/* | /* | |||
* Copyright 2002-2021 the original author or authors. | * Copyright 2002-2022 the original author or authors. | |||
* | * | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | * Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | * you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | * You may obtain a copy of the License at | |||
* | * | |||
* https://www.apache.org/licenses/LICENSE-2.0 | * https://www.apache.org/licenses/LICENSE-2.0 | |||
* | * | |||
* Unless required by applicable law or agreed to in writing, software | * Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | * distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
skipping to change at line 150 | skipping to change at line 150 | |||
* @param httpMethod the HTTP method (GET, POST, etc) | * @param httpMethod the HTTP method (GET, POST, etc) | |||
* @param url a URL template; the resulting URL will be encoded | * @param url a URL template; the resulting URL will be encoded | |||
* @param vars zero or more URI variables | * @param vars zero or more URI variables | |||
*/ | */ | |||
MockHttpServletRequestBuilder(HttpMethod httpMethod, String url, Object.. . vars) { | MockHttpServletRequestBuilder(HttpMethod httpMethod, String url, Object.. . vars) { | |||
this(httpMethod.name(), initUri(url, vars)); | this(httpMethod.name(), initUri(url, vars)); | |||
} | } | |||
private static URI initUri(String url, Object[] vars) { | private static URI initUri(String url, Object[] vars) { | |||
Assert.notNull(url, "'url' must not be null"); | Assert.notNull(url, "'url' must not be null"); | |||
Assert.isTrue(url.startsWith("/") || url.startsWith("http://") || | Assert.isTrue(url.startsWith("/") || url.startsWith("http://") || | |||
url.startsWith("https://"), "" + | url.startsWith("https://"), | |||
"'url' should start with a path or be a complete | () -> "'url' should start with a path or be a com | |||
HTTP URL: " + url); | plete HTTP URL: " + url); | |||
return UriComponentsBuilder.fromUriString(url).buildAndExpand(var s).encode().toUri(); | return UriComponentsBuilder.fromUriString(url).buildAndExpand(var s).encode().toUri(); | |||
} | } | |||
/** | /** | |||
* Alternative to {@link #MockHttpServletRequestBuilder(HttpMethod, Strin g, Object...)} | * Alternative to {@link #MockHttpServletRequestBuilder(HttpMethod, Strin g, Object...)} | |||
* with a pre-built URI. | * with a pre-built URI. | |||
* @param httpMethod the HTTP method (GET, POST, etc) | * @param httpMethod the HTTP method (GET, POST, etc) | |||
* @param url the URL | * @param url the URL | |||
* @since 4.0.3 | * @since 4.0.3 | |||
*/ | */ | |||
End of changes. 2 change blocks. | ||||
5 lines changed or deleted | 5 lines changed or added |