我试图使用Spring使用vCenter的WebClient生成一个支持包。当我使用cURL (甚至伪造头来模拟Java发送的内容)触发包创建时,一切都很好:
$ curl -A "Apache-HttpAsyncClient/5.1 (Java/14.0.2)" -X POST 'https://vcenter.internal.system:443/api/appliance/support-bundle?vmw-task=true' -H 'vmware-api-session-id: 4d63eec20a2fd6baadfef6ba9c308f92' -H 'Content-type: application/json' -d '{ "components": { "VirtualAppliance": [ "ApplianceManagement", "Rhttpproxy" ] }, "description": "bundle", "partition": "" }' --insecure
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 204 0 74 100 130 217 382 --:--:-- --:--:-- --:--:-- 601"8459589f-0bcc-4a88-b579-8996c97c66aa:com.vmware.appliance.support_bundle"当我从WebClient中做同样的事情时,我会得到一个奇怪的HTTP400错误:
{
"error_type": "INVALID_ARGUMENT",
"messages": [
{
"args": [
"operation-input",
"spec"
],
"default_message": "Structure operation-input is missing a field \"spec\"",
"id": "vapi.data.structure.field.missing"
}
]
}通过向cURL和添加一些冗长的日志记录,我看到发送的正文和头是相同的,因此这是一个非常神秘的问题。
发布于 2022-08-02 17:07:53
我在回答我自己的问题,因为我在网上任何地方都找不到与这个问题有关的任何东西。解决方案是强制HTTP客户端使用HTTP1.1
HttpAsyncClientBuilder clientBuilder = HttpAsyncClients.custom();
clientBuilder.setVersionPolicy(HttpVersionPolicy.FORCE_HTTP_1);
CloseableHttpAsyncClient client = clientBuilder.build();在查看了请求和响应的原始数据之后,我注意到cURL以纯文本发送标头,而Apache客户端显然对它们进行压缩。我怀疑在HTTP头解压缩或一般的HTTP/2处理中,vCenter的一方存在一些错误行为。
https://stackoverflow.com/questions/73211215
复制相似问题