如何在Java中向http请求方法添加新标头?

时间:2018-01-09 20:30:47

标签: java http http-headers

我需要在服务器中为请求实现特殊标头(以及一些新的响应)。我们这样说:

GET / HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Cache-Control: max-age=0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36
Upgrade-Insecure-Requests: 1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding: gzip, deflate, br
My-header-goes-here: example-value

如您所见,我想通过 My-header-goes-here 扩展 GET 的标准版本。我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:1)

spark://spark-master.service:7077