+2009-07-02 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+ * 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.
+
2009-07-02 Gonzalo Paniagua Javier <gonzalo@novell.com>
* ServicePointManager.cs: implement ServerCertificateValidationCallback.
return result;
}
- internal bool Write (HttpWebRequest request, byte [] buffer, int offset, int size)
+ internal bool Write (HttpWebRequest request, byte [] buffer, int offset, int size, ref string err_msg)
{
+ err_msg = null;
lock (this) {
if (Data.request != request)
throw new ObjectDisposedException (typeof (NetworkStream).FullName);
if (ssl && !certsAvailable)
GetCertificates ();
} catch (Exception e) {
+ err_msg = e.Message;
WebExceptionStatus wes = WebExceptionStatus.SendFailure;
- string msg = "Write";
+ string msg = "Write: " + err_msg;
if (e is WebException) {
HandleError (wes, e, msg);
return false;
requestWritten = true;
byte [] bytes = writeBuffer.GetBuffer ();
int length = (int) writeBuffer.Length;
- writeBuffer = null;
// Headers already written to the stream
return (length > 0) ? cnc.BeginWrite (request, bytes, 0, length, cb, state) : null;
}
return;
headersSent = true;
- if (!cnc.Write (request, headers, 0, headers.Length))
- throw new WebException ("Error writing request.", null, WebExceptionStatus.SendFailure, null);
+ string err_msg = null;
+ if (!cnc.Write (request, headers, 0, headers.Length, ref err_msg))
+ throw new WebException ("Error writing request: " + err_msg, null, WebExceptionStatus.SendFailure, null);
}
internal void WriteRequest ()
byte [] bytes = writeBuffer.GetBuffer ();
int length = (int) writeBuffer.Length;
- writeBuffer = null;
if (request.ContentLength != -1 && request.ContentLength < length) {
nextReadCalled = true;
cnc.Close (true);
disposed = true;
pending.WaitOne ();
byte [] chunk = Encoding.ASCII.GetBytes ("0\r\n\r\n");
- cnc.Write (request, chunk, 0, chunk.Length);
+ string err_msg = null;
+ cnc.Write (request, chunk, 0, chunk.Length, ref err_msg);
return;
}