Question

I have been writing a C# program to deal with and send web requests and they seem to be working as intended, however I have in my code the following two headers within my HttpWebRequest:

request.Accept = "application/xml";
request.Expect = "application/xml";

I am a little confused of the difference or which way round these are, could some one please clarify to me which is which or if I am wrong. Am I right in thinking Accept is what I am expecting them to take from me me (e.g an XML) and Expect is what they should return to me, i.e. what I am expecting in return.

Have I got this wrong? a lot of the stuff I can find on-line in documentation is a little vague and confusing for me to understand, am I even using expect correctly or should it be something completely different?

Any clarification would be fantastic, thanks

Was it helpful?

Solution

Avoid Expect. The Expect request-header field is used to indicate that particular server behaviors are required by the client. You do not specify MIME header types here as you do with Accept.

For more info see the HTTP/1.1 Definition at http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html (Expect is section 14.20).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top