Permalink
Browse files

2006-04-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>

	* WebConnection.cs: reset the challenge and the status code when
	creating the tunnel and sending the proxy auth. headers. Improve error
	message when there's an error creating the tunnel.
	* HttpWebRequest.cs: don't trigger an early throw for a POST that gets
	a 401 or 407 response.


svn path=/branches/mono-1-1-13/mcs/; revision=60023
  • Loading branch information...
1 parent 98c7aaa commit ac73df99bda9b7fcec984705efe113e1a9003c27 @gonzalop gonzalop committed Apr 28, 2006
@@ -1,3 +1,11 @@
+2006-04-27 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * WebConnection.cs: reset the challenge and the status code when
+ creating the tunnel and sending the proxy auth. headers. Improve error
+ message when there's an error creating the tunnel.
+ * HttpWebRequest.cs: don't trigger an early throw for a POST that gets
+ a 401 or 407 response.
+
2006-04-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* WebConnectionData.cs:
@@ -1030,7 +1030,8 @@ internal void SetResponseError (WebExceptionStatus status, Exception e, string w
void CheckSendError (WebConnectionData data)
{
// Got here, but no one called GetResponse
- if (data.StatusCode < 400)
+ int status = data.StatusCode;
+ if (status < 400 || status == 401 || status == 407)
return;
if (writeStream != null && asyncRead == null && !writeStream.CompleteRequestWritten) {
@@ -1142,7 +1143,7 @@ bool CheckFinalStatus (WebAsyncResult result)
WebExceptionStatus protoError = WebExceptionStatus.ProtocolError;
HttpStatusCode code = 0;
if (throwMe == null && webResponse != null) {
- code = webResponse.StatusCode;
+ code = webResponse.StatusCode;
if (!authCompleted && ((code == HttpStatusCode.Unauthorized && credentials != null) ||
(ProxyQuery && code == HttpStatusCode.ProxyAuthenticationRequired))) {
if (!usedPreAuth && CheckAuthorization (webResponse, code)) {
@@ -1187,8 +1188,13 @@ bool CheckFinalStatus (WebAsyncResult result)
if (throwMe == null) {
bool b = false;
int c = (int) code;
- if (allowAutoRedirect && c >= 300)
+ if (allowAutoRedirect && c >= 300) {
+ if (InternalAllowBuffering && writeStream.WriteBufferLength > 0) {
+ bodyBuffer = writeStream.WriteBuffer;
+ bodyBufferLength = writeStream.WriteBufferLength;
+ }
b = Redirect (result, code);
+ }
if (resp != null && c >= 300 && c != 304)
resp.ReadAll ();
@@ -175,6 +175,7 @@ bool CreateTunnel (HttpWebRequest request, Stream stream, out byte [] buffer)
sb.Append ("\r\nHost: ");
sb.Append (request.Address.Authority);
string challenge = Data.Challenge;
+ Data.Challenge = null;
bool have_auth = (request.Headers ["Proxy-Authorization"] != null);
if (have_auth) {
sb.Append ("\r\nProxy-Authorization: ");
@@ -187,11 +188,10 @@ bool CreateTunnel (HttpWebRequest request, Stream stream, out byte [] buffer)
sb.Append ("\r\nProxy-Authorization: ");
sb.Append (auth.Message);
}
- Data.Challenge = null;
}
-
sb.Append ("\r\n\r\n");
+ Data.StatusCode = 0;
byte [] connectBytes = Encoding.Default.GetBytes (sb.ToString ());
stream.Write (connectBytes, 0, connectBytes.Length);
@@ -202,7 +202,8 @@ bool CreateTunnel (HttpWebRequest request, Stream stream, out byte [] buffer)
Data.Challenge = result ["Proxy-Authenticate"];
return false;
} else if (status != 200) {
- HandleError (WebExceptionStatus.SecureChannelFailure, null, "CreateTunnel");
+ string msg = String.Format ("The remote server returned a {0} status code.", status);
+ HandleError (WebExceptionStatus.SecureChannelFailure, null, msg);
return false;
}

0 comments on commit ac73df9

Please sign in to comment.