HTTP POST内容类型
问题描述:
我有这样的HTTP POST服务: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
如何更改服务器的的Content-Type值应用/ xml? 我正在使用IIS和VB .NET。
谢谢。
答
Content-Type
请求标头描述了请求主体中数据的格式。
xmlstr=string
使用application/x-www-form-urlencoded
格式进行编码。
如果你说Content-Type: application/xml
那么我希望身体格式为XML(例如<xmlstr>string</xmlstr>
)。
发送到服务器的Content-Type对服务器响应的数据类型没有标准化影响。
The Accept
header可以请求特定内容类型:
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的查询字符串中的数据或正文中的数据来请求特定格式。
它总是取决于服务器端代码支持的内容。