java - 如何查看默认 JDK HttpURLConnection 的 header ?

标签 java http

getHeaderFields()但这会返回响应 HTTP 消息中的 header 。我想要请求消息中的 header ,而不是响应。

另外,Properties 和 Headers 有什么区别?好像setRequestProperty()正在设置标题,但我不确定。

最佳答案

如果您检查 getRequestProperties() 方法,您会发现您的猜测是正确的:

public Map<String,List<String>> getRequestProperties()

Returns an unmodifiable Map of general request properties for this connection. The Map keys are Strings that represent the request-header field names. Each Map value is a unmodifiable List of Strings that represents the corresponding field values.

关于java - 如何查看默认 JDK HttpURLConnection 的 header ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23931055/

相关文章:

java - 使用方法将数据添加到父类(super class)和数组

java - 将Symja和log4j-1.2.11添加到Android Studio后,Gradle构建缓慢

java - 当另一个设备以编程方式连接时禁用特定设备

http - 戈朗 http : how to route requests to handlers

Ruby 连接到 REST 服务

ajax - NodeJS HTTP GET 返回空体

objective-c - Objective-C 中的简单 http post 示例?

java - 删除 <br/> 标签后的所有空格

java - 使用 AbstractTableModel 将行添加到 JTable

http - 在 Go 中写入响应正文等待客户端读取?