Windows Phone 7 DataServicesClient请求标头接受gzip [英] Windows Phone 7 DataServicesClient Request Headers Accept gzip
问题描述
我有一个Windows Phone 7应用程序,该应用程序正在使用DataServicesClient访问WCF DataService(ODATA),并且我想让该服务压缩响应.
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.
我知道请求标头是否包含值为"gzip"的"Accept-Encoding"标头,WCF DS将压缩响应.
I know if the Request Headers includes "Accept-Encoding" header with the value of "gzip" the WCF DS will compress the response.
在WP7上使用DataServicesClient时,是否可以将此标头添加到请求中?请求标头集合似乎是只读的.我想做的是以下操作(但是Headers属性在此上下文中没有Add方法.)
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"); }
- 迈克尔
推荐答案
您应该能够使用以下代码修改标头集合
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";
}
这篇关于Windows Phone 7 DataServicesClient请求标头接受gzip的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!