oTAMAKOo / google-gdata

Automatically exported from code.google.com/p/google-gdata
0 stars 0 forks source link

Enable HTTP compression in all requests #491

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
GDataRequestFactory.UseGZip does not seem to work mainly because of UserAgent 
value. Implementation can perhaps be improved.

What steps will reproduce the problem?
1. Run IIS application pool under a user account credential
2. Run Fiddler under the above account in order to view if response if 
compressed.
3. Request headers has "Accept-Encoding:gzip"

What is the expected output? What do you see instead?
Response output is not compressed if UseGZip is set to true in code.

I have applied a quick hot-fix 
1) Change ConstructUserAgent() to return Google Chrome user agent
2) Inside EnsureWebRequest(), add 
((HttpWebRequest)this.Request).AutomaticDecompression = 
DecompressionMethods.GZip

(See attached request.cs for updated file)

With the above changes, HTTP response are compressed (see attached .PNG)

Original issue reported on code.google.com by wizlearn...@gmail.com on 21 Mar 2011 at 9:45

Attachments:

GoogleCodeExporter commented 8 years ago
Google servers return gzip-compressed output if the request headers contain 
"Accept-Encoding:gzip" AND the UserAgent contains the string "gzip".
I managed to get compressed responses without any changes to the current 
version of the library, my sample code is as follows:

string calendarUri = 
"https://www.google.com/calendar/feeds/default/allcalendars/full"; 
CalendarService service = new CalendarService("gzip-demo");
service.RequestFactory.UseGZip = true;
IGDataRequest request = 
service.RequestFactory.CreateRequest(GDataRequestType.Query, new 
Uri(calendarUri));
request.Credentials = new GDataCredentials("user@domain.com", "password");
request.Execute();  

Original comment by ccherub...@google.com on 13 Jun 2011 at 10:34

GoogleCodeExporter commented 8 years ago

Original comment by ccherub...@google.com on 22 Jun 2011 at 2:31