0

I want to add some custom headers into web request's header. I'm doing this by WebClient.Headers.Add("Header: Value") approach. There is not a problem with ASCII characters but non-ASCII characters.

Is it possible to change "Value of Header's encoding"?

kizanlik
  • 165
  • 3
  • 9
  • Why would you need to do this? – Esailija Feb 07 '13 at 12:28
  • I send some values to REST Api. Api gets those values and uses them for search in database, files etc. – kizanlik Feb 07 '13 at 12:42
  • REST API uses query strings, url and request body for input data.. not headers. – Esailija Feb 07 '13 at 12:45
  • The Api based on Microsoft's WebApi. It doesn't allow me send "request body". I also don't want to send values via query strings because of caching. I ran into troubles with that approach so, sending values via header is better for me. – kizanlik Feb 07 '13 at 12:59
  • You are deeply mistaken if you think a REST API doesn't allow you to send request bodies... they are the way to POST and PUT data to a restful service. Using headers for data is not restful or safe. – Esailija Feb 07 '13 at 13:02
  • I send requests with GET method (It makes very easy something "readonly" on the firewall by PUT or POST denial rule). GET method doesn't (actually shouldn't) have "request body".Yes. POST and PUT are another approaches but making decisions about "is it GET-POST?" or "is it POST-POST?" harder on the api side. – kizanlik Feb 07 '13 at 13:21
  • With GET you should just use query strings. Problems such as caching are easily workable, since if you can hack the server to somehow read your ad-hoc headers, you can probably configure the caching policy as well. Using header to pass data that should be in a query string has the same problems + many others. Such as encoding being undefined. – Esailija Feb 07 '13 at 13:29

0 Answers0