Skip to content

Commit

Permalink
Merge branch '6.0.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
rstoyanchev committed Sep 29, 2023
2 parents 95838e1 + 23162bb commit a6ab636
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public Mono<ClientHttpResponse> connect(HttpMethod method, URI uri,
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)))
Expand All @@ -156,6 +156,18 @@ public Mono<ClientHttpResponse> connect(HttpMethod method, URI uri,
});
}

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) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,7 @@ public boolean supports(Class<?> clazz) {
@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
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit a6ab636

Please sign in to comment.