When the stream returned by WebClient.OpenWrite() / OpenWriteAsync() /
OpenWriteTaskAsync(), we need to call GetResponse() and read the full
response.
Unfortunately, there is no async API available for this, so this API should
not be used in async applications.
UploadString call UploadData that encapsulates all exceptions in a WebException. ThreadInterruptedException were encapsulated into a WebException, so UploadStringAsync now uses e.InnerException is ThreadInterruptedException instead of trying to catch it.
This is mostly cosmetic and won't help unless you're sending a very large
buffer due to the kernel's internal buffering. Unfortunately, there is no
way of getting a notification when the data has actually been sent over the
wire - socket.Write() returns after the kernel has accepted the data.
On iOS, Stream.Read() returns 0 if you put the device to sleep while the
download is still running. We now work around that by checking whether the
file has been fully downloaded. Note that this only works if the server
included a Content-Length header.
Fixes#3924.
When using PUT as the method to upload a file using WebClient, the file
is uploaded as-is, without the multipart boundaries, headers,...
Fixes bug #2970.
(1) Consider the following example code:
WebClient client=new WebClient();
If you examine the client.Proxy property when running this code in .NET you will see, that the Proxy property reflects the current system proxy settings. However, Mono initializes the Proxy property in OpenRead()
(2) Mono's implementation of the WebClient.Proxy property described in (1) has a disadvantage. To understand that, consider der following example code:
WebClient client=new WebClient();
client.Proxy=null;
Explicitely setting the Proxy property to null ensures that .NET does not use any proxies when calling further methods of the client object. My patch provides exactly this functionality for Mono's WebClient when using the http or ftp protocol. This functionality can be very interesting for a lot of scenarios.
* WebClient.cs: handle compressed streams when automatic decompression
is turned on by a class derived from WebClient.
svn path=/trunk/mcs/; revision=160084
* WebClient.cs: fix handling of query string, whether it comes from
the address used or is part of the QueryString.
svn path=/trunk/mcs/; revision=153960
* WebClient.cs: rethrow WebExceptions instead of creating a new one
with less information on the actual error.
Fixes bug #526069.
svn path=/trunk/mcs/; revision=138855
* WebClient.cs: implement GetWebRequest and GetWebResponse. Use them
instead of SetupRequest and ProcessResponse.
svn path=/trunk/mcs/; revision=137673
* WebClient.cs: set the content length when uploading values. This
allows reusing the connection.
* WebConnectionStream.cs: SetHeaders() takes ownership of the buffer
and does not need to copy it any more. WriteRequest() wasn't always
setting 'requestWritten' to true.
* HttpWebRequest.cs: change in SetHeaders call.
svn path=/trunk/mcs/; revision=137497
zero-length string literal. Fixed exception argument name to match
MS.
* WebConnectionStream.cs: Throw a WebException that wraps an
IOException when closing the stream before all bytes are written.
svn path=/trunk/mcs/; revision=136543
* FtpWebResponse.cs: return a Null stream when there's no response to
be read.
* FtpWebRequest.cs: provide the error returned by the server in the
exception.
* WebClient.cs: set the correct method when doing a FTP upload.
Fixes bug #478451.
svn path=/trunk/mcs/; revision=127640
* FtpWebRequest.cs: avoid errors when creating a temporary Uri to get
the local path.
* WebClient.cs: when setting up the request for downloading, use the
default method. Fixes bug #477611.
svn path=/trunk/mcs/; revision=127449
* WebClient.cs: We catch exceptions that happen on the helper
async threads toa void terminating the application on errors, and
also raise a variant of the OnXXXXCompleted methods that take an
Exception argument.
Note that this differs from the .NET implementation in that
we actually raise a signal on error, and set the exception, and in
their case no error is ever raised.
We now call CompleteAsync in the OnXXXCompleted handlers to ensure
that the WebClient can be reused immediately by the callback.
This fixes#350621.
This also should fix the bug report on IRC where someone
complained that they could not "chain" invocations to XXXAsync
methods from the OnXXXXCompleted handlers due to the WebClient
refusing to work if there was an ongoing operation
svn path=/trunk/mcs/; revision=91959
* WebClient.cs: Do not validate method to be null, we do not do
that in OpenWrite, the detection is done later on.
Fixes#350622
svn path=/trunk/mcs/; revision=91867