多个Map的第二个键值对在httpHeader spring 4.1.7

时间:2018-05-18 17:54:02

标签: java spring http http-headers httprequest

我正在为HttpHeader发送如下的键和值,只有第一个键和值显示为标题。其余的键值附加到另一个标题值

 MultiValueMap<String, String> headers = new LinkedMultiValueMap<String, String>();

 headers.add("head1","result1");
 headers.add("head2","result2");
 headers.add("head3","result3");

 HttpEntity<String> requestEntity = new HttpEntity<String>("this is a body", headers);

然后我收到了webhook的请求,如下面的链接

请参考以下链接获取extact formate     https://webhook.site/#/8362e392-677c-4d29-97db-ba9999bae780/5729b001-de90-4dc5-836f-b0042b526b61/0

Headers
content-length  14
connection  close
accept-encoding gzip,deflate
user-agent  Apache-HttpClient/4.5 (Java/1.8.0_161)
content-type    text/plain;charset=ISO-8859-1
head1   result1
accept  text/plain, application/xml, text/xml, application/json,       application/*+xml, application/*+json, */* head2: result2 head3: result3
host    webhook.site

1 个答案:

答案 0 :(得分:0)

我不确定MultiValueMap<>是否与标题规范兼容。

将其替换为HttpHeaders,它适用于我

 HttpHeaders headers = new HttpHeaders();

 headers.add("head1","result1");
 headers.add("head2","result2");
 headers.add("head3","result3");