Commit Graph
82 Commits
Author SHA1 Message Date
Marcos Henrich a1e558f6c6 Reset stream position before doing CopyToAsync.
CopyToAsync begins copying at the current position.
2014-10-07 09:53:01 +01:00
Marcos Henrich aea4abc755 Call SetupRequestAsync only after ContentType changes. Fixes 19529. 2014-10-07 09:52:54 +01:00
Martin Baulig 7d8798c15d [System]: WebClient.OpenWrite() must get the response on close; fixes #10163.
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.
2014-08-25 18:15:49 +02:00
Martin Baulig d56c28373b [System]: Fix WebClient.UploadValuesTaskAsync(); bug #20359. 2014-08-25 18:15:48 +02:00
marcos henrich e2e64fada5 Changed UploadStringAsync to handle UploadString encapsulated exceptions.
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.
2014-06-03 16:23:22 +01:00
Marek Safar 4fbb65ae05 [http] Convert string output data using BOM header when available. Fixes #19667 2014-05-12 15:24:57 +02:00
Martin Baulig 42c568fb11 [System]: Split WebClient.UploadData() data into chunks and fire the event.
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.
2014-02-25 18:59:20 +01:00
Martin Baulig cd1f964bf7 Fix commit c31a58b656. 2013-06-27 06:13:50 +02:00
Martin Baulig c31a58b656 [System]: Make WebClient report an error when the download aborted prematurely.
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.
2013-06-26 13:31:05 +02:00
Marek Safar c3f11d07d3 Run On*Completed events on original context 2013-01-08 10:23:01 +01:00
Marek Safar a26e157547 Add missing ConfigureAwait 2013-01-02 18:19:29 +01:00
Martin Baulig 651408b4eb Fix #5899: WebClient.*Async() now correctly builds the query string.
I also added 'async_thread.IsBackground = true'.

These methods could also use some more love; I filed a new bug #6904
about that.
2012-09-04 21:24:18 +02:00
Miguel de Icaza 17ef544aa2 Copyright notices 2012-06-02 13:20:23 -04:00
Martin Baulig 58218aeb66 Add .NET 4.5 async upload methods to WebClient. 2012-06-02 17:44:21 +02:00
Martin Baulig c1e5cdd85e More .NET 4.5 async work in WebClient.
* System.Net/WebClient.cs: Support cancelation.

* Test/System.Net/WebClientTestAsync.cs: New nunit tests.
2012-06-02 17:44:07 +02:00
Martin Baulig 17958f9bef Add .NET 4.5 async methods to WebClient. 2012-06-02 16:21:36 +02:00
Gonzalo Paniagua Javier 30dcaff4b9 Trigger the UploadProgressChanged event wen uploading a file.
Fixes bug #3100.
2012-03-22 00:17:48 -04:00
Gonzalo Paniagua Javier c10e388ea7 Fix rethrow of the interrupted exception
Fixes bug #2483.
2012-03-06 20:56:15 -05:00
Gonzalo Paniagua Javier c621b27d45 UploadFile+PUT does not wrap the file in a multipart envelope
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.
2012-01-19 12:23:24 -05:00
Sebastien Pouliot 5463644837 Provide total, not the number of bytes read, in DownloadData. Fix bug #2482 2011-12-19 14:11:40 -05:00
Martin 7cab44e7fa Commit 6a9937d216 is not correct. WebClient.Proxy should return WebRequest.DefaultProxy if WebClient.Proxy has NOT been set before. 2011-11-29 13:44:54 +01:00
Martin 62d56f05a5 Fixes some naming conventions. 2011-10-28 16:41:40 +03:00
Martin 6a9937d216 Behaviour of using proxies in WebClient is different compared to .NET
(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.
2011-10-25 10:51:58 +03:00
Marek Safar c9b3000b68 Fix parameter names 2011-10-07 10:11:28 +01:00
Gonzalo Paniagua Javier d0d40cb751 [webclient] Process uri.UserInfo when present
If there are no crendetials, the Uri might have them.
	Based on a patch by QuickJack.
	Fixes bug #688007.
2011-04-29 11:53:19 +02:00
Gonzalo Paniagua Javier 5fbcc7cd2d [webclient] Only set the credentials when they are not null.
Setting the credentials to null makes FtpWebRequest throw.
	Fixes bug #688007.
2011-04-17 13:58:32 -04:00
Marek Safar aad016fd87 Clean up few more warnings 2010-10-15 15:20:25 +01:00
Gonzalo Paniagua Javier 142eef3161 Fix the boundary in UploadFile().
* WebClient.cs: the last delimiter has 2 hyphens appended to the boundary to signal it is indeed the last one.
	Fixes bug #554817.
2010-08-09 18:01:05 -04:00
Gonzalo Paniagua Javier fc98a0f2bc 2010-07-16 Gonzalo Paniagua Javier <[email protected]>
* WebClient.cs: ignore values set in CachePolicy and
	UseDefaultCredentials instead of throwing NIEX.


svn path=/trunk/mcs/; revision=160504
2010-07-16 19:02:59 +00:00
Gonzalo Paniagua Javier cd45fc688f 2010-07-08 Gonzalo Paniagua Javier <[email protected]>
* WebClient.cs: handle compressed streams when automatic decompression
	is turned on by a class derived from WebClient.


svn path=/trunk/mcs/; revision=160084
2010-07-08 21:04:45 +00:00
Gonzalo Paniagua Javier 154877147a 2010-03-21 Gonzalo Paniagua Javier <[email protected]>
* 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
2010-03-21 18:06:56 +00:00
Miguel de Icaza 3fc0cdfff0 2010-03-20 Miguel de Icaza <[email protected]>
* WebClient.cs: Drop the pre-2.0 support

svn path=/trunk/mcs/; revision=153944
2010-03-20 22:45:29 +00:00
Miguel de Icaza 11ca00c93b 2010-03-19 Miguel de Icaza <[email protected]>
* Eliminate warnings in a bunch of places.

svn path=/trunk/mcs/; revision=153923
2010-03-19 21:46:30 +00:00
Gonzalo Paniagua Javier cff198e18c 2010-03-06 Gonzalo Paniagua Javier <[email protected]>
* WebClient.cs: fix for UploadStringAsync(). Closes bug #577818.
	Patch by Atsushi.


svn path=/trunk/mcs/; revision=153180
2010-03-06 16:30:33 +00:00
Alexandre Gomes 195ead9481 2009-10-23 Alexandre Gomes <[email protected]>
* Test/System.Net/WebClientTest.cs:
	* System.Net/WebClient.cs: Fixed GetWebRequest overriding problems, bug: 
	  https://bugzilla.novell.com/show_bug.cgi?id=549580


svn path=/trunk/mcs/; revision=144753
2009-10-23 18:26:49 +00:00
Gonzalo Paniagua Javier de80b74af3 2009-07-28 Gonzalo Paniagua Javier <[email protected]>
* 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
2009-07-28 17:26:51 +00:00
Gonzalo Paniagua Javier cae867a722 2009-07-10 Gonzalo Paniagua Javier <[email protected]>
* WebClient.cs: implement GetWebRequest and GetWebResponse. Use them
	instead of SetupRequest and ProcessResponse.


svn path=/trunk/mcs/; revision=137673
2009-07-10 05:45:10 +00:00
Gonzalo Paniagua Javier 547e70a03b 2009-07-07 Gonzalo Paniagua Javier <[email protected]>
* 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
2009-07-07 14:57:51 +00:00
Gert Driesen 6f8bd0b8a8 * WebClient.cs: Use lowercase hex bytes to match MS. Avoid using
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
2009-06-20 13:17:16 +00:00
Robert Jordan 2ee8aa88d1 2009-06-05 Robert Jordan <[email protected]>
* WebClient.cs (UploadValuesCore): Encode POST arguments with UTF-8.
	Fixes bug #484795.


svn path=/trunk/mcs/; revision=135532
2009-06-05 14:53:24 +00:00
Gonzalo Paniagua Javier 7aeb0747ee 2009-02-23 Gonzalo Paniagua Javier <[email protected]>
* WebClient.cs: append the QueryString in DownloadData.
	Fixes bug #323788.


svn path=/trunk/mcs/; revision=127699
2009-02-23 05:10:10 +00:00
Gonzalo Paniagua Javier f65e2cc9cc 2009-02-21 Gonzalo Paniagua Javier <[email protected]>
* 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
2009-02-21 23:30:00 +00:00
Gonzalo Paniagua Javier c0bc4cf75d 2009-02-19 Gonzalo Paniagua Javier <[email protected]>
* 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
2009-02-19 20:13:58 +00:00
Marek Safar 225f1c9198 Warnings cleanup
svn path=/trunk/mcs/; revision=111790
2008-08-28 09:12:00 +00:00
Atsushi Eno 318f234c5b 2008-08-05 Atsushi Enomoto <[email protected]>
* WebClient.cs : it should not invoke delegate directly, but should
	  call overridable OnDownloadProgressChanged.


svn path=/trunk/mcs/; revision=109641
2008-08-05 05:36:44 +00:00
Marek Safar bdd9de656e Fixed few warnings
svn path=/trunk/mcs/; revision=107455
2008-07-08 10:34:18 +00:00
Gert Driesen d1251bd902 * WebClient.cs: Do not add trailing CRLF in UploadValuesCore. Fixes
standalone test for bug #351049.

svn path=/trunk/mcs/; revision=92723
2008-01-12 09:52:20 +00:00
Miguel de Icaza 6162ce03bd 2007-12-27 Miguel de Icaza <[email protected]>
* 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
2007-12-27 18:30:23 +00:00
Miguel de Icaza f926a3544e 2007-12-24 Miguel de Icaza <[email protected]>
* 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
2007-12-24 19:55:08 +00:00
Miguel de Icaza 9b1df4c381 2007-12-16 Miguel de Icaza <[email protected]>
* WebClient.cs: Got the arguments in the wrong order, fix

svn path=/trunk/mcs/; revision=91371
2007-12-16 05:38:06 +00:00