Merge branch '6.0.x'

This commit is contained in:
rstoyanchev 2023-09-29 18:00:52 +01:00
commit a6ab636614
3 changed files with 17 additions and 9 deletions

View File

@ -139,7 +139,7 @@ public class ReactorClientHttpConnector implements ClientHttpConnector, SmartLif
HttpClient.RequestSender requestSender = this.httpClient
.request(io.netty.handler.codec.http.HttpMethod.valueOf(method.name()));
requestSender = (uri.isAbsolute() ? requestSender.uri(uri) : requestSender.uri(uri.toString()));
requestSender = setUri(requestSender, uri);
return requestSender
.send((request, outbound) -> requestCallback.apply(adaptRequest(method, uri, request, outbound)))
@ -156,6 +156,18 @@ public class ReactorClientHttpConnector implements ClientHttpConnector, SmartLif
});
}
private static HttpClient.RequestSender setUri(HttpClient.RequestSender requestSender, URI uri) {
if (uri.isAbsolute()) {
try {
return requestSender.uri(uri);
}
catch (Exception ex) {
// Fall back on passing it in as a String
}
}
return requestSender.uri(uri.toString());
}
private ReactorClientHttpRequest adaptRequest(HttpMethod method, URI uri, HttpClientRequest request,
NettyOutbound nettyOutbound) {

View File

@ -93,11 +93,7 @@ public class StringHttpMessageConverter extends AbstractHttpMessageConverter<Str
@Override
protected String readInternal(Class<? extends String> clazz, HttpInputMessage inputMessage) throws IOException {
Charset charset = getContentTypeCharset(inputMessage.getHeaders().getContentType());
long length = inputMessage.getHeaders().getContentLength();
byte[] bytes = (length >= 0 && length <= Integer.MAX_VALUE ?
inputMessage.getBody().readNBytes((int) length) :
inputMessage.getBody().readAllBytes());
return new String(bytes, charset);
return StreamUtils.copyToString(inputMessage.getBody(), charset);
}
@Override

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 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.
@ -36,8 +36,8 @@ public class UnknownContentTypeException extends RestClientException {
private static final long serialVersionUID = 2759516676367274084L;
@SuppressWarnings("serial")
private final Type targetType;
private transient final Type targetType;
private final MediaType contentType;