简体   繁体   中英

HTTP POST Content-Type

I have this HTTP POST service:

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 ? I'm using IIS and VB .NET.

Thanks.

The Content-Type request header describes the format of the data in the body of the request.

xmlstr=string is encoded using the application/x-www-form-urlencoded format.

If you said Content-Type: application/xml then I'd expect the body for me formatted as XML (eg <xmlstr>string</xmlstr> ).

The Content-Type you send to the server has no standardised influence over what type of data the server responds with.

The Accept header can request specific content types:

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.

It will always depend on what the server side code supports.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM