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.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论