You've already forked linux-packaging-mono
Imported Upstream version 4.0.4.1
Former-commit-id: d8eb832a9a4b58a238f2e069a0b68c70082f8790
This commit is contained in:
@@ -340,6 +340,8 @@ namespace System.Net.Http
|
||||
wrequest.ContentLength = content.Headers.ContentLength.Value;
|
||||
}
|
||||
|
||||
wrequest.ResendContentFactory = content.CopyTo;
|
||||
|
||||
var stream = await wrequest.GetRequestStreamAsync ().ConfigureAwait (false);
|
||||
await request.Content.CopyToAsync (stream).ConfigureAwait (false);
|
||||
} else if (HttpMethod.Post.Equals (request.Method) || HttpMethod.Put.Equals (request.Method) || HttpMethod.Delete.Equals (request.Method)) {
|
||||
|
@@ -81,6 +81,12 @@ namespace System.Net.Http
|
||||
}
|
||||
}
|
||||
|
||||
// Only used by HttpWebRequest internals which is not async friendly
|
||||
internal void CopyTo (Stream stream)
|
||||
{
|
||||
CopyToAsync (stream).Wait ();
|
||||
}
|
||||
|
||||
public Task CopyToAsync (Stream stream)
|
||||
{
|
||||
return CopyToAsync (stream, null);
|
||||
|
@@ -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;
|
||||
|
@@ -362,6 +362,41 @@ namespace MonoTests.System.IO.Compression
|
||||
backing.Close();
|
||||
}
|
||||
#endif
|
||||
|
||||
[Test]
|
||||
[ExpectedException (typeof (ArgumentException))]
|
||||
public void CheckBufferOverrun ()
|
||||
{
|
||||
byte[] data = new byte [20];
|
||||
MemoryStream backing = new MemoryStream ();
|
||||
DeflateStream compressing = new DeflateStream (backing, CompressionLevel.Fastest, true);
|
||||
compressing.Write (data, 0, data.Length + 1);
|
||||
compressing.Close ();
|
||||
backing.Close ();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Bug28777_EmptyFlush ()
|
||||
{
|
||||
MemoryStream backing = new MemoryStream ();
|
||||
DeflateStream compressing = new DeflateStream (backing, CompressionLevel.Fastest, true);
|
||||
compressing.Flush ();
|
||||
compressing.Close ();
|
||||
backing.Close ();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Bug28777_DoubleFlush ()
|
||||
{
|
||||
byte[] buffer = new byte [4096];
|
||||
MemoryStream backing = new MemoryStream ();
|
||||
DeflateStream compressing = new DeflateStream (backing, CompressionLevel.Fastest, true);
|
||||
compressing.Write (buffer, 0, buffer.Length);
|
||||
compressing.Flush ();
|
||||
compressing.Flush ();
|
||||
compressing.Close ();
|
||||
backing.Close ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1 +1 @@
|
||||
635d63e502807da4ea4ad941b6e58bfab43bd37a
|
||||
68b84e24a06bbb6bb78ef224608dc4eba15d5030
|
@@ -1 +1 @@
|
||||
2b5f667533551ac33fc9de43b43a62b448b55a90
|
||||
17f4de6638d19cbc68f60a4d532798d87ab7302b
|
@@ -1 +1 @@
|
||||
5e889cf1e66abc75e57bafd92c7139ab2c808069
|
||||
e29dbe6efa356793ba4738a7a2d9858233c5d502
|
@@ -1 +1 @@
|
||||
4218f3c3bb5d10cef11ff7c790e5ade5d1b86898
|
||||
2a993e8625896ec805afccd0668cb8f016e84399
|
@@ -1 +1 @@
|
||||
2bcd9a0ee7ae4393575a446e424e0cd5017ba4c1
|
||||
0bf4ff5424f83891362cc450b801e8168bf5b777
|
@@ -1 +1 @@
|
||||
ff31c170be712465ad92e7a9205369a179b7fd06
|
||||
58b35960f78d990b0abdf6138caee16ddcde82c8
|
@@ -1 +1 @@
|
||||
02b350ac4078a8f6791373d728b2866b52268350
|
||||
32112b9a947cfe490e82c9e32a4201dc758359d9
|
@@ -1 +1 @@
|
||||
ab62521ff428443441e7b5469865bfa7555b53a7
|
||||
bf09282b13961dddc7fd50d446f6246c14bff292
|
Reference in New Issue
Block a user