Author: siwuzzz
Date: Mon Jul 9 17:22:53 2007
New Revision: 206
Modified:
trunk/clients/cs/src/core/request.cs
Log:
src/core/request.cs:
- More robust handling of gzipped streams.
Modified: trunk/clients/cs/src/core/request.cs
==============================================================================
--- trunk/clients/cs/src/core/request.cs (original)
+++ trunk/clients/cs/src/core/request.cs Mon Jul 9 17:22:53 2007
@@ -194,8 +194,8 @@
protected bool disposed;
/// <summary>set wheter or not this request should use GZip</summary>
private bool useGZip;
-
- private GZipStream gzippedStream;
+ /// <summary>stream from the response</summary>
+ private Stream responseStream;
//////////////////////////////////////////////////////////////////////
@@ -431,8 +431,6 @@
}
Tracing.TraceCall("calling the real execution over the
webresponse");
this.webResponse = this.webRequest.GetResponse();
- if (this.webResponse != null)
- this.useGZip =
(string.Compare(((HttpWebResponse)this.webResponse).ContentEncoding, "gzip",
true) == 0);
}
catch (WebException e)
{
@@ -440,11 +438,17 @@
GDataRequestException gde = new
GDataRequestException("Execution of request failed: " +
this.targetUri.ToString(), e);
throw gde;
}
+ if (this.webResponse != null)
+ this.responseStream = this.webResponse.GetResponseStream();
if (this.webResponse is HttpWebResponse)
{
HttpWebResponse response = this.webResponse as HttpWebResponse;
HttpWebRequest request = this.webRequest as HttpWebRequest;
+ this.useGZip = (string.Compare(response.ContentEncoding,
"gzip", true) == 0);
+ if (this.useGZip == true)
+ this.responseStream = new GZipStream(this.responseStream,
CompressionMode.Decompress);
+
Tracing.Assert(response != null, "The response should not be
NULL");
Tracing.Assert(request != null, "The request should not be
NULL");
@@ -510,17 +514,7 @@
//////////////////////////////////////////////////////////////////////
public virtual Stream GetResponseStream()
{
- if (this.webResponse == null)
- return (null);
-
- if (this.useGZip == true)
- {
- if (this.gzippedStream == null)
- this.gzippedStream = new
GZipStream(this.webResponse.GetResponseStream(), CompressionMode.Decompress);
- return (this.gzippedStream);
- }
- else
- return this.webResponse.GetResponseStream();
+ return (this.responseStream);
}
/////////////////////////////////////////////////////////////////////////////
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Data API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/google-help-dataapi?hl=en
-~----------~----~----~----~------~----~------~--~---