由new URI(string)
解析的示例URI字符串,其中包含已编码的保留字符"#" (%23)在查询字符串中:
http://localhost:34455/ldp-test-43272e5c-1e3f-4bb8-8541-fa5ea6d6567a?predicate=http%3A%2F%2Fwww.w3.org%2Fns%2Foa%23hasBody
然后将URI对象简单地传递给HttpRequest.newBuilder(uri)
这是日志,第一个条目显示服务器处理的请求字符串被截断,但响应和请求URI显示完整的字符串:
127.0.0.1 - - [22/Feb/2018:10:30:51 +0000] "GET /ldp-test-43272e5c-
1e3f-4bb8-8541-fa5ea6d6567a?predicate=http://www.w3.org/ns/oa
HTTP/1.1" 200 3 "-" "-" 64
INFO [2018-02-22 10:30:51,137] cool.pandora.ldpclient.LdpClientImpl:
request URI is http://localhost:34455/ldp-test-43272e5c-1e3f-4bb8-
8541-fa5ea6d6567a?
predicate=http%3A%2F%2Fwww.w3.org%2Fns%2Foa%23hasBody
INFO [2018-02-22 10:30:51,141] cool.pandora.ldpclient.LdpClientImpl:
response URI is http://localhost:34455/ldp-test-43272e5c-1e3f-4bb8-
8541-fa5ea6d6567a?
predicate=http%3A%2F%2Fwww.w3.org%2Fns%2Foa%23hasBody
INFO [2018-02-22 10:30:51,141] cool.pandora.ldpclient.LdpClientImpl:
http version is HTTP_1_1
INFO [2018-02-22 10:30:51,141] cool.pandora.ldpclient.LdpClientImpl:
status code is 200
INFO [2018-02-22 10:30:51,141] cool.pandora.ldpclient.LdpClientImpl:
final request URI is http://localhost:34455/ldp-test-43272e5c-1e3f-
4bb8-8541-fa5ea6d6567a?
predicate=http%3A%2F%2Fwww.w3.org%2Fns%2Foa%23hasBody
INFO [2018-02-22 10:30:51,141] cool.pandora.ldpclient.LdpClientImpl:
Content Length is[3]
这似乎是jdk.incubator.http中的错误,而不是URI。
在Exchange中我不清楚是否会发生额外的URI字符串构建或构造,但如果查询字符串在没有重新编码的情况下被解码,那么这将是我作为嫌疑人的第一个猜测。
也许有人可以独立验证这一点?
另外,我认为它不是服务器实现,因为curl
的相同请求URI(在非测试实例上)有效。
172.18.0.1 - - [22/Feb/2018:09:22:31 +0000] "GET /test10?
predicate=http%3A%2F%2Fwww.w3.org%2Fns%2Foa%23hasBody HTTP/1.1" 200
795 "-" "curl/7.55.1" 35
答案 0 :(得分:1)
感谢您报告此问题。它确实是JDK HTTP客户端代码中的一个错误。以下JIRA已被提交跟踪它: https://bugs.openjdk.java.net/browse/JDK-8198716