c# - Telling RestSharp *not* to add a specific HTTP header -


i trying call rest service c# asp.net 4.0 application using restsharp.

it's straightforward post call https:// address; code (checkstatusrequest plain simple dto 4 or 5 string , int properties - nothing fancy):

public checkstatusresponse checkstatus(checkstatusrequest request) {     // set restclient     restclient client = new restclient();     string uri = "https://.......";      // create request (see below)     irestrequest restrequest = createrequestwithheaders(url, method.post);      // add body request     restrequest.addbody(request);      // execute call     var restresponse = _restclient.execute<checkstatusresponse>(restrequest); }     // set request private irestrequest createrequestwithheaders(string uri, method method) {     // define request     restrequest request = new restrequest(uri, method);      // add 2 required http headers     request.addheader("accept", "application/json");     request.addheader("content-type", "application/json");      // define json format     request.requestformat = dataformat.json;      // attach json.net serializer restsharp     request.jsonserializer = new restsharpjsonnetserializer();      return request; } 

the problem i'm having when send these requests through fiddler see what's going on request gets third , unwanted http header:

post https://-some-url- http/1.1 accept: application/json user-agent: restsharp/104.4.0.0 content-type: application/json host: **********.com content-length: 226 accept-encoding: gzip, deflate   <<<=== 1 here unwanted! connection: keep-alive 

i have accept-encoding http header, never specified (and don't want have in there). , response no longer proper json (which i'm able parse), gzipped binary data instead (which doesn't real when trying json-deserialize)....

how can rid of third unwanted http header?

  • i tried set else - whatever enter gets appended settings
  • i tried somehow "clear" http header - without success
  • i tried finding property on restclient or restrequest classes specify "do not use gzip"

looking @ sources (http.sync.cs , http.async.cs) of restsharp can see these values hardcoded:

webrequest.automaticdecompression =      decompressionmethods.deflate | decompressionmethods.gzip | decompressionmethods.none; 

there open issue describes problem. opened august 2014 still not solved. think can leave comment there , maybe pay attention.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -