Proactively reject URLs without target address
Issue: SPR-15782
This commit is contained in:
		
							parent
							
								
									cbe5a67687
								
							
						
					
					
						commit
						147368eccc
					
				| 
						 | 
					@ -68,6 +68,10 @@ public class ReactorClientHttpConnector implements ClientHttpConnector {
 | 
				
			||||||
	public Mono<ClientHttpResponse> connect(HttpMethod method, URI uri,
 | 
						public Mono<ClientHttpResponse> connect(HttpMethod method, URI uri,
 | 
				
			||||||
			Function<? super ClientHttpRequest, Mono<Void>> requestCallback) {
 | 
								Function<? super ClientHttpRequest, Mono<Void>> requestCallback) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (!uri.isAbsolute()) {
 | 
				
			||||||
 | 
								return Mono.error(new IllegalArgumentException("URI is not absolute: " + uri));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return this.httpClient
 | 
							return this.httpClient
 | 
				
			||||||
				.request(adaptHttpMethod(method),
 | 
									.request(adaptHttpMethod(method),
 | 
				
			||||||
						uri.toString(),
 | 
											uri.toString(),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -568,6 +568,16 @@ public class WebClientIntegrationTests {
 | 
				
			||||||
		}).verifyComplete();
 | 
							}).verifyComplete();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Test // SPR-15782
 | 
				
			||||||
 | 
						public void absoluteUri() throws Exception {
 | 
				
			||||||
 | 
							String uri = "/api/v4/groups/1";
 | 
				
			||||||
 | 
							Mono<ClientResponse> responseMono = WebClient.builder().build().get().uri(uri).exchange();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							StepVerifier.create(responseMono)
 | 
				
			||||||
 | 
									.expectErrorMessage("URI is not absolute: " + uri)
 | 
				
			||||||
 | 
									.verify(Duration.ofSeconds(5));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@SuppressWarnings("serial")
 | 
						@SuppressWarnings("serial")
 | 
				
			||||||
	private static class MyException extends RuntimeException {
 | 
						private static class MyException extends RuntimeException {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue