[英]HTTP POST Content-Type
I have this HTTP POST service: 我有这个HTTP POST服务:
POST /test/test.asmx/getValues HTTP/1.1
Host: localhost
Content-Type: application/x-www-form-urlencoded
Content-Length: length
xmlstr=string
I want have this service: 我想要这项服务:
POST /test/test.asmx/getValues HTTP/1.1
Host: localhost
Content-Type: application/xml
Content-Length: length
xmlstr=string
How can i change Server's Content-Type value to application/xml ? 如何将Server的Content-Type值更改为application / xml ? I'm using IIS and VB .NET.
我正在使用IIS和VB .NET。
Thanks. 谢谢。
The Content-Type
request header describes the format of the data in the body of the request. Content-Type
请求标头描述了请求Content-Type
中的数据格式。
xmlstr=string
is encoded using the application/x-www-form-urlencoded
format. xmlstr=string
使用application/x-www-form-urlencoded
格式application/x-www-form-urlencoded
。
If you said Content-Type: application/xml
then I'd expect the body for me formatted as XML (eg <xmlstr>string</xmlstr>
). 如果您说
Content-Type: application/xml
那么我希望该正文的格式为XML(例如<xmlstr>string</xmlstr>
)。
The Content-Type you send to the server has no standardised influence over what type of data the server responds with. 您发送到服务器的Content-Type对服务器响应的数据类型没有标准化的影响。
The Accept
header can request specific content types: 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
… but the server side code has to pay attention to it and respect it. …但是服务器端代码必须注意并尊重它。
Servers might also allow specific formats to be requested with non-standard request headers, data stored in the query string of the URL, or data in the body. 服务器还可能允许使用非标准的请求标头,URL的查询字符串中存储的数据或正文中的数据来请求特定格式。
It will always depend on what the server side code supports. 这将始终取决于服务器端代码支持的内容。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.