Imported Upstream version 3.8.0

Former-commit-id: 6a76a29bd07d86e57c6c8da45c65ed5447d38a61
This commit is contained in:
Jo Shields
2014-09-04 09:07:35 +01:00
parent a575963da9
commit fe777c5c82
1062 changed files with 12460 additions and 5983 deletions

View File

@@ -39,6 +39,7 @@ namespace System.Net
{
enum State {
None,
PartialSize,
Body,
BodyFinished,
Trailer
@@ -139,9 +140,9 @@ namespace System.Net
void InternalWrite (byte [] buffer, ref int offset, int size)
{
if (state == State.None) {
if (state == State.None || state == State.PartialSize) {
state = GetChunkSize (buffer, ref offset, size);
if (state == State.None)
if (state == State.PartialSize)
return;
saved.Length = 0;
@@ -262,7 +263,7 @@ namespace System.Net
ThrowProtocolViolation ("Cannot parse chunk size.");
}
return State.None;
return State.PartialSize;
}
chunkRead = 0;

View File

@@ -181,7 +181,7 @@ namespace System.Net
}
value = header.Substring (beginQ, pos - beginQ);
pos += 2;
pos += useQuote ? 2 : 1;
return true;
}
}

View File

@@ -1405,10 +1405,12 @@ namespace System.Net
string data2 = UploadString ((Uri) args [0], (string) args [1], (string) args [2]);
OnUploadStringCompleted (
new UploadStringCompletedEventArgs (data2, null, false, args [3]));
} catch (ThreadInterruptedException){
OnUploadStringCompleted (
new UploadStringCompletedEventArgs (null, null, true, args [3]));
} catch (Exception e){
if (e is ThreadInterruptedException || e.InnerException is ThreadInterruptedException) {
OnUploadStringCompleted (
new UploadStringCompletedEventArgs (null, null, true, args [3]));
return;
}
OnUploadStringCompleted (
new UploadStringCompletedEventArgs (null, e, false, args [3]));
}});

View File

@@ -356,8 +356,6 @@ namespace System.Net
byte [] buffer = new byte [1024];
MemoryStream ms = new MemoryStream ();
bool gotStatus = false;
WebHeaderCollection headers = null;
while (true) {
int n = stream.Read (buffer, 0, 1024);
@@ -369,7 +367,8 @@ namespace System.Net
ms.Write (buffer, 0, n);
int start = 0;
string str = null;
headers = new WebHeaderCollection ();
bool gotStatus = false;
WebHeaderCollection headers = new WebHeaderCollection ();
while (ReadLine (ms.GetBuffer (), ref start, (int) ms.Length, ref str)) {
if (str == null) {
int contentLen = 0;
@@ -399,13 +398,22 @@ namespace System.Net
continue;
}
int spaceidx = str.IndexOf (' ');
if (spaceidx == -1) {
string[] parts = str.Split (' ');
if (parts.Length < 2) {
HandleError (WebExceptionStatus.ServerProtocolViolation, null, "ReadHeaders2");
return null;
}
status = (int) UInt32.Parse (str.Substring (spaceidx + 1, 3));
if (String.Compare (parts [0], "HTTP/1.1", true) == 0)
Data.ProxyVersion = HttpVersion.Version11;
else if (String.Compare (parts [0], "HTTP/1.0", true) == 0)
Data.ProxyVersion = HttpVersion.Version10;
else {
HandleError (WebExceptionStatus.ServerProtocolViolation, null, "ReadHeaders2");
return null;
}
status = (int)UInt32.Parse (parts [1]);
gotStatus = true;
}
}
@@ -841,6 +849,8 @@ namespace System.Net
string header = (sPoint.UsesProxy) ? "Proxy-Connection" : "Connection";
string cncHeader = (Data.Headers != null) ? Data.Headers [header] : null;
bool keepAlive = (Data.Version == HttpVersion.Version11 && this.keepAlive);
if (Data.ProxyVersion != null && Data.ProxyVersion != HttpVersion.Version11)
keepAlive = false;
if (cncHeader != null) {
cncHeader = cncHeader.ToLower ();
keepAlive = (this.keepAlive && cncHeader.IndexOf ("keep-alive", StringComparison.Ordinal) != -1);

View File

@@ -39,6 +39,7 @@ namespace System.Net
public string StatusDescription;
public WebHeaderCollection Headers;
public Version Version;
public Version ProxyVersion;
public Stream stream;
public string[] Challenge;
ReadState _readState;