Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs/class
diff options
context:
space:
mode:
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>2010-07-09 01:04:05 +0400
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>2010-07-09 01:04:05 +0400
commit7b0a263fca25c51e6465a0e9ad56883e4f8d1bc2 (patch)
tree7d2dd527b38eb00eb98ed0d240aa714959f8fb2d /mcs/class
parent4ae701cad00a152bc0bf289cfd24bf7efa078a40 (diff)
2010-07-08 Gonzalo Paniagua Javier <gonzalo@novell.com>
* WebClient.cs: handle compressed streams when automatic decompression is turned on by a class derived from WebClient. svn path=/branches/mono-2-6/mcs/; revision=160082
Diffstat (limited to 'mcs/class')
-rw-r--r--mcs/class/System/System.Net/WebClient.cs31
1 files changed, 17 insertions, 14 deletions
diff --git a/mcs/class/System/System.Net/WebClient.cs b/mcs/class/System/System.Net/WebClient.cs
index 8ada916e77a..ac2dc8d79b4 100644
--- a/mcs/class/System/System.Net/WebClient.cs
+++ b/mcs/class/System/System.Net/WebClient.cs
@@ -272,9 +272,7 @@ namespace System.Net
try {
request = SetupRequest (address);
- WebResponse response = GetWebResponse (request);
- Stream st = response.GetResponseStream ();
- return ReadAll (st, (int) response.ContentLength, userToken);
+ return ReadAll (request, userToken);
} catch (ThreadInterruptedException){
if (request != null)
request.Abort ();
@@ -549,9 +547,7 @@ namespace System.Net
stream.Write (data, 0, contentLength);
}
- WebResponse response = GetWebResponse (request);
- Stream st = response.GetResponseStream ();
- return ReadAll (st, (int) response.ContentLength, userToken);
+ return ReadAll (request, userToken);
} catch (ThreadInterruptedException){
if (request != null)
request.Abort ();
@@ -661,9 +657,7 @@ namespace System.Net
reqStream.Write (realBoundary, 0, realBoundary.Length);
reqStream.Close ();
reqStream = null;
- WebResponse response = GetWebResponse (request);
- Stream st = response.GetResponseStream ();
- resultBytes = ReadAll (st, (int) response.ContentLength, userToken);
+ resultBytes = ReadAll (request, userToken);
} catch (ThreadInterruptedException){
if (request != null)
request.Abort ();
@@ -771,9 +765,7 @@ namespace System.Net
}
tmpStream.Close ();
- WebResponse response = GetWebResponse (request);
- Stream st = response.GetResponseStream ();
- return ReadAll (st, (int) response.ContentLength, userToken);
+ return ReadAll (request, userToken);
} catch (ThreadInterruptedException) {
request.Abort ();
throw;
@@ -993,10 +985,21 @@ namespace System.Net
return request;
}
- byte [] ReadAll (Stream stream, int length, object userToken)
+ byte [] ReadAll (WebRequest request, object userToken)
{
+ WebResponse response = GetWebResponse (request);
+ Stream stream = response.GetResponseStream ();
+ int length = (int) response.ContentLength;
+ HttpWebRequest wreq = request as HttpWebRequest;
+
+ if (length > -1 && wreq != null && (int) wreq.AutomaticDecompression != 0) {
+ string content_encoding = ((HttpWebResponse) response).ContentEncoding;
+ if (((content_encoding == "gzip" && (wreq.AutomaticDecompression & DecompressionMethods.GZip) != 0)) ||
+ ((content_encoding == "deflate" && (wreq.AutomaticDecompression & DecompressionMethods.Deflate) != 0)))
+ length = -1;
+ }
+
MemoryStream ms = null;
-
bool nolength = (length == -1);
int size = ((nolength) ? 8192 : length);
if (nolength)