[英]Invalid HTML response when using Java webclient
Am working with Reactive Webclient in Spring, and am having some difficulty determining why am getting the below response format from a GET request:我在 Spring 中使用 Reactive Webclient,并且在确定为什么从 GET 请求中获取以下响应格式时遇到了一些困难:
�\jj��T{�8��?�t(O�"V$�@��)���5�����~?��J�t"�� ��EEΕ7�b��,�u�i�=��k���3�ӡ�������m,��ꔁu�T낙*��{�DZ�l�`����{� ��M��+mB)��E{�UtG���ʘJ#ؠ�]j<u�?6�`h���.���𢚾�n��?�ʋ*��#%�w'<L��d�Ly����R�>���$�O�����—o�}�� �����v���{���?����r�;
This is the code am using below for the request:这是我在下面用于请求的代码:
return webClient
.get()
.uri(URI.create(uri))
.accept(MediaType.TEXT_HTML, MediaType.APPLICATION_XHTML_XML)
.acceptCharset(StandardCharsets.UTF_8, StandardCharsets.ISO_8859_1)
.header("Accept-Encoding", "gzip, deflate, br")
.retrieve()
.bodyToMono(String.class);
WebClient setup is as below: WebClient 设置如下:
HttpClient client = HttpClient.create()
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeout)
.followRedirect(true)
.secure()
.responseTimeout(Duration.ofMillis(readTimeoutMillis));
return WebClient.builder()
.clientConnector(new ReactorClientHttpConnector(client))
.build();
What am I missing?我错过了什么?
Looks like response is encoded, probably gzipped, especially that you have declared to the server, that you are able to decode gzip, deflate and br encodings with看起来响应是编码的,可能是 gzip 压缩的,尤其是你已经向服务器声明的,你能够解码 gzip、deflate 和 br 编码
Accept-Encoding: gzip,deflate,br
You can remove .header("Accept-Encoding", "gzip, deflate, br")
and see if the server is willing to send you a plain text response.您可以删除
.header("Accept-Encoding", "gzip, deflate, br")
并查看服务器是否愿意向您发送纯文本响应。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.