开发者

Windows Phone 7 DataServicesClient Request Headers Accept gzip

开发者 https://www.devze.com 2023-02-04 19:41 出处:网络
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 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


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";
}


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号