+2009-06-09 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+ * HttpWebRequest.cs: follow MS docs when throwing
+ ProtocolViolationException at the beginning of an asynchronous
+ operation. Fixes bug #465613.
+
2009-06-08 Gonzalo Paniagua Javier <gonzalo@novell.com>
* WebConnectionStream.cs: throw a WebException instead of an IOException.
}
#endif
- void CommonChecks (bool putpost)
- {
- if (method == null)
- throw new ProtocolViolationException ("Method is null.");
-
- if (putpost && contentLength == -1 && !sendChunked && !allowBuffering)
- throw new ProtocolViolationException ("Content-Length not set");
-
- string transferEncoding = TransferEncoding;
- if (!sendChunked && transferEncoding != null && transferEncoding.Trim () != "")
- throw new ProtocolViolationException ("SendChunked should be true.");
- }
-
public override IAsyncResult BeginGetRequestStream (AsyncCallback callback, object state)
{
if (aborted)
if (method == null || !send)
throw new ProtocolViolationException ("Cannot send data when method is: " + method);
- CommonChecks (send);
+ if (contentLength == -1 && !sendChunked && !allowBuffering && KeepAlive)
+ throw new ProtocolViolationException ("Content-Length not set");
+
+ string transferEncoding = TransferEncoding;
+ if (!sendChunked && transferEncoding != null && transferEncoding.Trim () != "")
+ throw new ProtocolViolationException ("SendChunked should be true.");
lock (locker)
{
public override IAsyncResult BeginGetResponse (AsyncCallback callback, object state)
{
+ if (method == null)
+ throw new ProtocolViolationException ("Method is null.");
+
bool send = (method == "PUT" || method == "POST");
- if (send) {
- if (ContentLength == -1 && !SendChunked && !AllowWriteStreamBuffering)
- throw new ProtocolViolationException ("Content-Length not set");
- }
+ if (send && contentLength == -1 && !sendChunked && !allowBuffering && KeepAlive)
+ throw new ProtocolViolationException ("Content-Length not set");
+
+ string transferEncoding = TransferEncoding;
+ if (!sendChunked && transferEncoding != null && transferEncoding.Trim () != "")
+ throw new ProtocolViolationException ("SendChunked should be true.");
- CommonChecks (send);
Monitor.Enter (locker);
getResponseCalled = true;
if (asyncRead != null && !haveResponse) {