Imported Upstream version 4.0.4.1

Former-commit-id: d8eb832a9a4b58a238f2e069a0b68c70082f8790
This commit is contained in:
Xamarin Public Jenkins
2015-08-25 18:44:33 -04:00
parent c7df8a8f93
commit 363056e66e
34 changed files with 115 additions and 39 deletions

View File

@ -110,6 +110,9 @@ namespace System.Net
AuthorizationState auth_state, proxy_auth_state;
string host;
[NonSerialized]
internal Action<Stream> ResendContentFactory;
// Constructors
static HttpWebRequest ()
{
@ -226,9 +229,15 @@ namespace System.Net
internal bool InternalAllowBuffering {
get {
return (allowBuffering && (method != "HEAD" && method != "GET" &&
method != "MKCOL" && method != "CONNECT" &&
method != "TRACE"));
return allowBuffering && MethodWithBuffer;
}
}
bool MethodWithBuffer {
get {
return method != "HEAD" && method != "GET" &&
method != "MKCOL" && method != "CONNECT" &&
method != "TRACE";
}
}
@ -1306,8 +1315,7 @@ namespace System.Net
bodyBuffer = null;
writeStream.Close ();
}
} else if (method != "HEAD" && method != "GET" && method != "MKCOL" && method != "CONNECT" &&
method != "TRACE") {
} else if (MethodWithBuffer) {
if (getResponseCalled && !writeStream.RequestWritten)
return writeStream.WriteRequestAsync (result);
}
@ -1606,12 +1614,28 @@ namespace System.Net
(ProxyQuery && !proxy_auth_state.IsCompleted && code == HttpStatusCode.ProxyAuthenticationRequired)) {
if (!usedPreAuth && CheckAuthorization (webResponse, code)) {
// Keep the written body, so it can be rewritten in the retry
if (InternalAllowBuffering) {
if (writeStream.WriteBufferLength > 0) {
bodyBuffer = writeStream.WriteBuffer;
bodyBufferLength = writeStream.WriteBufferLength;
if (MethodWithBuffer) {
if (AllowWriteStreamBuffering) {
if (writeStream.WriteBufferLength > 0) {
bodyBuffer = writeStream.WriteBuffer;
bodyBufferLength = writeStream.WriteBufferLength;
}
return true;
}
//
// Buffering is not allowed but we have alternative way to get same content (we
// need to resent it due to NTLM Authentication).
//
if (ResendContentFactory != null) {
using (var ms = new MemoryStream ()) {
ResendContentFactory (ms);
bodyBuffer = ms.ToArray ();
bodyBufferLength = bodyBuffer.Length;
}
return true;
}
return true;
} else if (method != "PUT" && method != "POST") {
bodyBuffer = null;
return true;