Windows Phone 7 DataServicesClient Request Headers Accept gzip

依然范特西╮ 提交于 2019-12-12 01:57:22

问题


I have a Windows Phone 7 application that is utilizing the DataServicesClient to access a WCF DataService (ODATA) and I want to ask the service to compress the response.

I know if the Request Headers includes "Accept-Encoding" header with the value of "gzip" the WCF DS will compress the response.

Is there a way to add this header to the Request when using the DataServicesClient on WP7? The Request Headers collection appears to be readonly. What I would like to be able to do is the following (but the Headers property does not have an Add method in this context.)

void entities_SendingRequest(object sender, SendingRequestEventArgs e) { e.Headers.Add("Accept-Encoding", "gzip"); }
  • Michael

回答1:


You should be able to modify header collection with following code

private void OnSendingRequest(object sender, System.Data.Services.Client.SendingRequestEventArgs e)
{
    e.RequestHeaders["Accept-Encoding"] = "gzip";
}



回答2:


This looks a lot like your other active question ;)

As mentioned on that question, it looks like the ODATA client has no way for you to modify the headers of a request before it is sent, though you could make a feature request.



来源:https://stackoverflow.com/questions/4706535/windows-phone-7-dataservicesclient-request-headers-accept-gzip

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!