GET request return content appears to be set by content-type header?

Topics: Web Api
Jan 6, 2012 at 12:09 PM

I'm currently using the Web API Preview 5 release and have noticed something when using the WCF Web API Test Client

If I make a GET request and set the Content-Type header (with no Accept header at all) to either XML or JSON I get my response back in the appropriate XML or JSON format, however I thought this would only happen if an Accept header was set?

Is this expected/designed behaviour?

The reason I ask is that this 'feature' could be useful when using the basic System.Net.WebClient class to make requests as the Accept Header cannot be set, but I do not want to make a habit of using this 'feature' if it is possible that it is a bug and may be removed in a future update.

If anyone can provide any concrete detail that would be much appreciated

Thanks

Gareth

Coordinator
Jan 6, 2012 at 8:20 PM

Yes, in the absence of an Accept header one of the heuristics we use is to replicate in the response the content-type of the request.

Daniel Roth

Jan 9, 2012 at 7:41 AM

Many thanks for the reply Daniel, I had a feeling that would be the case but couldn't find the detail when searching - great to have confirmation!

Gareth