2

I asked this question before the final WP7 platform was released and never received a definitive answer from the team - it appears that the http stack in WP7 DOES NOT support compression. The way I found this out was by using fiddler while running the emulator - when I request an ODATA feed that is compressed when received by Silverlight3/4 - is not compressed when received by an WP7 app.

Does anyone have confirmation that the Silverlight HTTP stack on WP7 DOES/DOES NOT support http compression?

thanks Michael

MIantosca
  • 833
  • 1
  • 10
  • 33
  • How are specifying that you can receive compressed content? (Which headers are you setting in you HttpWebRequest?) – Matt Lacey Jan 11 '11 at 19:22
  • it isn't compressed *when received*? What does that mean? The *sender* would have to compress it, so that implies to me whatever header you think you are setting on WP7 is either incorrect or stripped out by the http stack. – John Gardner Jan 11 '11 at 19:38
  • I am not building up the request manually - I am using ODATA WP7 client - on the desktop version - the request sends the appropriate header to request compressed content - not sure why the WP7 version does not behave the same way – MIantosca Jan 12 '11 at 14:25

1 Answers1

1

In response to my question on twitter "Do you know if it's possible to support gzip encoding for REST services?", Joe Marini (Principal Program Manager at Microsoft for Web platform on Windows Phone) replied "Yes, gzip is supported."

The longer answer is that compressed HTTP content is supported, but you can't change the Accept-Encoding header in an HTTP request to request that the response is compressed. However, if the response is compressed, then you can receive, decompress, and handle that response.

I'm currently working on a WP7 application that has exactly this problem, which we have worked round by using a different header to request a compressed response (X-Accept-Encoding), but this requires that the server understands this custom header.

You might the find the Hammock library useful; I think it supports GZIP compression via the X-Accept-Encoding.

Derek Lakin
  • 16,179
  • 36
  • 51
  • I assume this will require me to make the request to the ODATA service directly - preventing me from using the WP7 DataServicesClient - which provides the request and response processing to/from ODATA feeds. I will look at the DataServiceClient to see if there is anyway to get a reference to the request before it is sent to the WCF data service. – MIantosca Jan 15 '11 at 19:31
  • I want to be able to this: void entities_SendingRequest(object sender, SendingRequestEventArgs e) { e.Headers.Add("Accept-Encoding", "gzip"); } but the headers collection is readonly – MIantosca Jan 15 '11 at 19:47
  • If the ODATA client lirbary for WP7 won't alllow you to customize the headers of the request, then you won't be able to request a compressed response, unfortunately. I believe the WP7 ODATA client is still in relative infancy, so you could always request it as a new feature. That said, are you sure that you actually need a compressed response? Is there so much data? – Derek Lakin Jan 17 '11 at 08:26
  • I was able to reduce the original payload from 450KB down to 70KB by reducing the number properties downloaded with the inital request - it is reasonably fast. When I modified the request headers (manually in fiddler) to include Accept-Encoding gzip - it was reduced to about 8KB - just trying to optimize as much as possible -- but I can live with the 70KB. – MIantosca Jan 17 '11 at 16:42