![](/img/trans.png)
[英]how to add 'Content-Type' header in (HTTP GET) Rest request header collection using HttpClient?
[英]HTTP POST Content-Type
我有这个HTTP POST服务:
POST /test/test.asmx/getValues HTTP/1.1
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: length
xmlstr=string
我想要这项服务:
POST /test/test.asmx/getValues HTTP/1.1
Host: localhost
Content-Type: application/xml
Content-Length: length
xmlstr=string
如何将Server的Content-Type值更改为application / xml ? 我正在使用IIS和VB .NET。
谢谢。
Content-Type
请求标头描述了请求Content-Type
中的数据格式。
xmlstr=string
使用application/x-www-form-urlencoded
格式application/x-www-form-urlencoded
。
如果您说Content-Type: application/xml
那么我希望该正文的格式为XML(例如<xmlstr>string</xmlstr>
)。
您发送到服务器的Content-Type对服务器响应的数据类型没有标准化的影响。
Accept
标头可以请求特定的内容类型:
POST /test/test.asmx/getValues HTTP/1.1
Host: localhost
Accept: application/xml
Content-Type: application/x-www-form-urlencoded
Content-Length: length
xmlstr=string
…但是服务器端代码必须注意并尊重它。
服务器还可能允许使用非标准的请求标头,URL的查询字符串中存储的数据或正文中的数据来请求特定格式。
这将始终取决于服务器端代码支持的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.