Commit Graph
84 Commits
Author SHA1 Message Date
Gonzalo Paniagua Javier b1248b22e4 [HttpWebRequest] Can't ignore erros here 2011-02-10 17:25:15 -05:00
Gonzalo Paniagua Javier b92b165ddb [HttpWebRequest] Error handling for POST/PUT
When we get an error from the server before writing an entire
	unbuffered response, the server might close the connection leading to
	write errors. Ignore those and return the actual HTTP status code from
	the original server error.
2011-02-10 17:25:15 -05:00
Gonzalo Paniagua Javier 604d5faa0b More StringComparison.Ordinal
Use StringComparison.Ordinal when calling IndexOf to find the index of
	an ASCII string.
2010-10-31 17:23:18 -04:00
Gonzalo Paniagua Javier b24939c61c Create only 1 callback instance for read/write
Read/Write were creating one callback instance per call. Now we keep
	the same delegate around for all the calls.
2010-10-02 01:41:40 -04:00
Gonzalo Paniagua Javier 6a4600c8ec Adapt to changes in exceptions policy for TP.
These exception were being thrown, sometimes, in a threadpool thread and then
ignored.
2010-07-30 01:54:00 -04:00
Gonzalo Paniagua Javier eafc6c8b08 2009-10-17 Gonzalo Paniagua Javier <[email protected]>
* WebConnectionStream.cs: add 3 missing DoCallback() calls in
	EndRead/EndWrite.


svn path=/trunk/mcs/; revision=144315
2009-10-18 02:09:20 +00:00
Gonzalo Paniagua Javier ae20ad47f0 2009-08-13 Gonzalo Paniagua Javier <[email protected]>
* HttpWebRequest.cs:
	* WebConnectionStream.cs: if there's an error writing the headers from
	a buffered request, propagate the error instead of hiding it and
	causing a different one later (ie, ObjectDisposedException instead of
	the original WebException). This happened when posting without
	Content-Length set to an HTTPS url without validating the server
	certificate.


svn path=/trunk/mcs/; revision=139885
2009-08-13 22:12:18 +00:00
Gonzalo Paniagua Javier 27e633cf32 2009-07-22 Gonzalo Paniagua Javier <[email protected]>
* WebConnectionStream.cs: when sending a 0-length POST, ignore further
	writes instead of throwing.
	Fixes bug #524049.


svn path=/trunk/mcs/; revision=138447
2009-07-22 19:58:51 +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 8d403f0381 * WebConnectionStream.cs: Move and improve argument checks to match MS.
Modified CanRead and CanWrite to return false when instance is disposed.
* HttpWebRequestTest.cs: Enabled tests, and removed test that is now
covered by two separate CanTimeout tests for request and response
stream.
* HttpWebResponseStreamTest.cs: Enabled tests.

svn path=/trunk/mcs/; revision=137450
2009-07-06 19:58:00 +00:00
Gonzalo Paniagua Javier 781e4faf6c 2009-07-02 Gonzalo Paniagua Javier <[email protected]>
* WebConnection.cs: provide better error message when there's an error
	writing.
	* WebConnectionStream.cs: don't nullify the buffer until
	CheckFinalStatus() decides that there are no more authentication
	retries or redirects.


svn path=/trunk/mcs/; revision=137332
2009-07-02 23:03:11 +00:00
Gonzalo Paniagua Javier 77e7d3d183 fix
svn path=/trunk/mcs/; revision=137239
2009-07-02 07:34:09 +00:00
Gonzalo Paniagua Javier 7ff2c1978d 2009-07-02 Gonzalo Paniagua Javier <[email protected]>
* HttpWebRequest.cs: avoid duplicating Accept-Encoding if GetHeaders()
	is called twice.
	* WebConnectionStream.cs: don't send a 0 content length for non-write
	requests.


svn path=/trunk/mcs/; revision=137233
2009-07-02 07:33:12 +00:00
Gonzalo Paniagua Javier 08a92a49eb 2009-06-28 Gonzalo Paniagua Javier <[email protected]>
* WebConnectionStream.cs: when buffering the response, we have to set
	the internal length and regenerate the headers.


svn path=/trunk/mcs/; revision=137043
2009-06-28 04:03:49 +00:00
Gonzalo Paniagua Javier d89546ba92 2009-06-26 Gonzalo Paniagua Javier <[email protected]>
* HttpWebRequest.cs: don't send Content-Length header when SendChunked
	is enabled.
	* WebConnectionStream.cs: send the headers immediately when possible.
	When writing the request before a Close(), if there was an exception
	it was lost.


svn path=/trunk/mcs/; revision=137019
2009-06-26 22:45:35 +00:00
Gonzalo Paniagua Javier 7584df6cf8 2009-06-25 Gonzalo Paniagua Javier <[email protected]>
* WebAsyncResult.cs: new field that tells us if the request is being
	written automatically because we reached the content length.
	* WebConnection.cs:
	* WebConnectionStream.cs: make sure we only access the NetworkStream
	while we own it. Automatically write the request when we reach
	ContentLength number of bytes. Kill the write buffer as soon as
	possible. Don't use the buffer at all when chunked encoding is
	enabled.

	Fixes bugs #515931 and #510642.

svn path=/trunk/mcs/; revision=136900
2009-06-25 23:23:24 +00:00
Gonzalo Paniagua Javier f3f57ffb5d 2009-06-21 Gonzalo Paniagua Javier <[email protected]>
* WebConnectionStream.cs: close the underlying socket if there's an
	exception when closing the stream. Fixes bug #514996.


svn path=/trunk/mcs/; revision=136572
2009-06-22 01:47:57 +00:00
Gert Driesen e9ff61a03b * HttpWebRequestTest.cs: Improved and enabled test for bug #510642.
* WebConnectionStream.cs: Keep count of all bytes written, and perform
write overflow check in both buffered and non-buffered writing (if
not using chunked transfer encoding). Fixes bug #510642.

svn path=/trunk/mcs/; revision=136570
2009-06-21 19:09:27 +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
Gonzalo Paniagua Javier 4bfc82f892 2009-06-08 Gonzalo Paniagua Javier <[email protected]>
* WebConnectionStream.cs: throw a WebException instead of an IOException.


svn path=/trunk/mcs/; revision=135704
2009-06-08 22:26:59 +00:00
Atsushi Eno f5d1dc6c2c 2009-02-16 Atsushi Enomoto <[email protected]>
* WebConnectionStream.cs : use request only after it is set.


svn path=/trunk/mcs/; revision=126994
2009-02-16 05:45:36 +00:00
Gonzalo Paniagua Javier 17efcb2270 2009-02-13 Gonzalo Paniagua Javier <[email protected]>
* WebConnectionStream.cs: implemente (Read|Write)Timeout.
	Fixes bug #348159.


svn path=/trunk/mcs/; revision=126842
2009-02-13 15:09:07 +00:00
Gonzalo Paniagua Javier b528a9481f 2009-02-06 Gonzalo Paniagua Javier <[email protected]>
* WebConnectionStream.cs: set the content length to 0 when the
	response is not supposed to have any content.


svn path=/trunk/mcs/; revision=126090
2009-02-06 19:33:19 +00:00
Miguel de Icaza b36f2aa0dd 2009-02-05 Miguel de Icaza <[email protected]>
* WebConnectionStream.cs: Prevent a nullref here.   This might
	have to be backported to 2.2 and 2.4

svn path=/trunk/mcs/; revision=125823
2009-02-05 06:10:57 +00:00
Gonzalo Paniagua Javier f1c1d40b44 2009-01-14 Gonzalo Paniagua Javier <[email protected]>
* WebConnectionStream.cs: if the buffer has been killed, return -1 for
	its length. Fixes regression in System.Runtime.Remoting.


svn path=/trunk/mcs/; revision=123449
2009-01-15 04:56:16 +00:00
Gonzalo Paniagua Javier 538c44650f 2009-01-13 Gonzalo Paniagua Javier <[email protected]>
* HttpConnection.cs: we were not writing the headers for 0-length
	responses.
	* WebConnectionStream.cs: for 204/304 responses with an explicit
	content-length of 0, release the socket only once.
	Fixes bug #465638.


svn path=/trunk/mcs/; revision=123250
2009-01-13 20:32:26 +00:00
Gonzalo Paniagua Javier 34e930f822 2008-10-30 Gonzalo Paniagua Javier <[email protected]>
* WebConnectionStream.cs: when there's a NTLM authentication in
	progress, don't let the connection be used by the next request if we
	have the entire response in the input buffer.


svn path=/trunk/mcs/; revision=117511
2008-10-30 19:17:53 +00:00
Gonzalo Paniagua Javier 07c165832b 2008-10-23 Gonzalo Paniagua Javier <[email protected]>
* HttpWebRequest.cs: don't call ProxyRequest twice.
	* WebConnectionData.cs: remove unused fields.

	* WebConnection.cs:
	* WebConnectionStream.cs: when setting the input buffer, check to see
	if the entire response is already there and free up the request slot.
	Fixes bug #423156.

	* ResponseStream.cs:
	* HttpListenerResponse.cs: buffer the headers so that they are sent
	together with the data on the first Write (if any). The fix above
	didn't work with our HttpListener without this.


svn path=/trunk/mcs/; revision=116868
2008-10-23 19:11:33 +00:00
Gonzalo Paniagua Javier 61bbe5b41b 2008-10-08 Gonzalo Paniagua Javier <[email protected]>
* WebConnection.cs:
	* ServicePoint.cs:
	* WebConnectionGroup.cs:
	* HttpWebRequest.cs:
	* WebConnectionStream.cs: reuse the same connection when doing NTLM
	authentication. Fixes bug #323375.
	Implemented support for UnsafeAuthenticatedConnectionSharing.


svn path=/trunk/mcs/; revision=115265
2008-10-08 20:16:33 +00:00
Gonzalo Paniagua Javier b67928068d 2008-09-19 Gonzalo Paniagua Javier <[email protected]>
* WebConnectionStream.cs: when receiving a 0 content-length, free up
	the slot for the next request immediately.
	Fixes bug #427974.


svn path=/trunk/mcs/; revision=113610
2008-09-20 01:53:59 +00:00
Miguel de Icaza 5e52009db7 Apply patch from Atsushi Enomoto to fix #397627
svn path=/trunk/mcs/; revision=111562
2008-08-25 19:45:39 +00:00
Zoltan Varga 2efbbd2f1d 2008-08-23 Zoltan Varga <[email protected]>
* WebConnectionStream.cs (WriteRequest): Fix the copying in the
	previous patch, when bytes.Length != length.

svn path=/trunk/mcs/; revision=111456
2008-08-23 01:43:05 +00:00
Miguel de Icaza 9cc22599f0 2008-08-22 Zoltan Varga <[email protected]>
* WebConnectionStream.cs (WriteRequest): For small requests,
	cluster together the header + body in a single write call, avoids
	the latency problems observed in an TLS application that makes
	many web service calls. 

2008-08-22  Geoff Norton  <[email protected]>

	* WebConnection.cs: Set NoDelay

svn path=/trunk/mcs/; revision=111430
2008-08-22 21:30:31 +00:00
Gonzalo Paniagua Javier 516285ad2f 2007-07-14 Gonzalo Paniagua Javier <[email protected]>
* WebConnectionStream.cs: implement the CanTimeout for 2.0. Fixes
	bug #81504.


svn path=/trunk/mcs/; revision=81997
2007-07-14 23:04:17 +00:00
Gert Driesen 049dd55113 * WebConnectionStream.cs: On read timeout, throw WebException with
status Timeout instead of IOException.

svn path=/trunk/mcs/; revision=77633
2007-05-18 12:24:36 +00:00
Gonzalo Paniagua Javier a60c59b7e2 2006-12-24 Gonzalo Paniagua Javier <[email protected]>
* WebConnectionStream.cs: fix error in my last patch. Thanks to Felipe
	Almeida.


svn path=/trunk/mcs/; revision=70036
2006-12-25 05:09:15 +00:00
Gonzalo Paniagua Javier 39ce8024a4 2006-12-23 Gonzalo Paniagua Javier <[email protected]>
* WebConnection.cs:
	* HttpWebRequest.cs:
	* WebConnectionStream.cs: detect errors writing headers earlier and
	avoid race that showed up with SSL. Fixes bug #80234.


svn path=/trunk/mcs/; revision=69986
2006-12-23 08:23:50 +00:00
Gonzalo Paniagua Javier f02c844aea 2006-03-16 Gonzalo Paniagua Javier <[email protected]>
* WebConnectionStream.cs: avoid Begin/EndWrite when the body length is
	zero.


svn path=/trunk/mcs/; revision=58084
2006-03-16 19:26:03 +00:00
Gonzalo Paniagua Javier a9850902ba 2006-03-13 Gonzalo Paniagua Javier <[email protected]>
* HttpWebRequest.cs: send the request if ContentLength is set for
	POST/PUT, the request stream has that exact amount of bytes in it and
	we're trying to get the response stream.

	This way, closing the request stream is not needed in order to actually
	send the request. Fixes bug #77753.

	* WebConnectionStream.cs: throw if the number of bytes written is
	greater than the specified request content length.


svn path=/trunk/mcs/; revision=57920
2006-03-13 22:57:58 +00:00
Gonzalo Paniagua Javier f84027dc3f 2005-07-03 Gonzalo Paniagua Javier <[email protected]>
* WebConnectionStream.cs: initiate writing the body before trying to
	read. This fixes the performance problems observed in web services.
	Closes bug #75455.


svn path=/trunk/mcs/; revision=46896
2005-07-03 23:22:51 +00:00
Gonzalo Paniagua Javier 437307379f 2005-06-26 Gonzalo Paniagua Javier <[email protected]>
* WebConnection.cs: if cnc.EndRead throws, mark the asyncresult as done.
	* WebConnectionStream.cs: if we're done with the body of a chunk, don't
	require the next chunk header to be there, as some servers might close
	the connection (while also sending 'Connection: close').


svn path=/trunk/mcs/; revision=46512
2005-06-26 05:51:18 +00:00
Gonzalo Paniagua Javier 16d1a69c18 2005-06-10 Gonzalo Paniagua Javier <[email protected]>
* WebConnection.cs:
	* HttpWebRequest.cs:
	* WebConnectionStream.cs: initiate the polling for input data after
	sending the header so that we detect any response that the server sends
	back even if we're still trying to write the request for a POST/PUT.
	If we get the response (or an error) before any one calls GetResponse(),
	keep it around instead of ignoring it.


svn path=/trunk/mcs/; revision=45785
2005-06-10 17:53:44 +00:00
Gonzalo Paniagua Javier aca2ff8b90 2005-05-03 Gonzalo Paniagua Javier <[email protected]>
* WebConnection.cs: removed a 'slightly' important line by mistake.
	* WebConnectionStream.cs: if the transfer encoding is chunked, ignore
	content-length header if present.


svn path=/trunk/mcs/; revision=43952
2005-05-03 17:25:49 +00:00
Gonzalo Paniagua Javier 780515fa29 2005-05-03 Gonzalo Paniagua Javier <[email protected]>
* WebConnection.cs: no need to use an AutoResetEvent.
	* WebConnectionStream.cs: don't start any more reads on the socket
	after getting a 0 signalling the end. This fixes Ben's infamous foo.cs
	test.


svn path=/trunk/mcs/; revision=43916
2005-05-03 09:41:51 +00:00
Gonzalo Paniagua Javier 52392433ed 2005-04-17 Gonzalo Paniagua Javier <[email protected]>
* WebConnectionStream.cs: if the BeginRead/BeginWrite is completed
	synchronously, no need to create the ManualResetEvent to wait on.


svn path=/trunk/mcs/; revision=43178
2005-04-17 23:07:26 +00:00
Gonzalo Paniagua Javier 90747718b0 ahoy
svn path=/trunk/mcs/; revision=43130
2005-04-16 21:44:05 +00:00
Gonzalo Paniagua Javier 1be9ca7a33 2005-04-16 Gonzalo Paniagua Javier <[email protected]>
* WebConnectionStream.cs: call SetComplete in EndWrite when we're not
	buffering the request body. Fixes bug #74673.

	* WebAsyncResult.cs: renamed field.


svn path=/trunk/mcs/; revision=43129
2005-04-16 21:41:05 +00:00
Gonzalo Paniagua Javier 127582b89e oops
svn path=/trunk/mcs/; revision=43017
2005-04-14 23:03:31 +00:00
Gonzalo Paniagua Javier d43aab1f7b 2005-04-14 Gonzalo Paniagua Javier <[email protected]>
* WebConnectionStream.cs:
	* WebAsyncResult.cs: ensure we only call EndRead once per async. result.
	Update total before invoking the callback when present.


svn path=/trunk/mcs/; revision=43016
2005-04-14 22:40:16 +00:00
Gonzalo Paniagua Javier 89f42a88c6 2005-04-11 Gonzalo Paniagua Javier <[email protected]>
* WebConnection.cs:
	* WebConnectionStream.cs: don't start reading until we've sent at least
	the headers. This way we ensure that a Write happens before any Read,
	which is needed by the SSL code.


svn path=/trunk/mcs/; revision=42792
2005-04-11 16:47:54 +00:00