HttpURLConnection post 请求头
时间: 2023-10-12 21:04:45 浏览: 82
对于HttpURLConnection的POST请求,可以使用setRequestProperty方法来设置请求头header的值。例如,可以使用以下代码来设置一个名为"test-header"的请求头,并将其值设置为"get-header-value":
```java
httpURLConnection.setRequestProperty("test-header", "get-header-value");
```
这样,在发送POST请求时,请求头中就会包含这个自定义的请求头。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [使用HttpURLConnection发送get和post请求](https://blog.csdn.net/forwardyzk/article/details/45364463)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
阅读全文