Imported Upstream version 3.10.0

Former-commit-id: 172c8e3c300b39d5785c7a3e8dfb08ebdbc1a99b
This commit is contained in:
Jo Shields
2014-10-04 11:27:48 +01:00
parent fe777c5c82
commit 8b9b85e7f5
970 changed files with 20242 additions and 31308 deletions

View File

@@ -53,13 +53,11 @@ namespace System.Net
{
}
#if !TARGET_JVM
// Methods
void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)
{
base.GetObjectData (info, context);
}
#endif
public override void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)
{

View File

@@ -282,7 +282,6 @@ namespace System.Net {
}
#if !TARGET_JVM
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern static bool GetHostByName_internal(string host, out string h_name, out string[] h_aliases, out string[] h_addr_list);
@@ -291,7 +290,6 @@ namespace System.Net {
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern static bool GetHostName_internal(out string h_name);
#endif
static void Error_11001 (string hostName)
{
@@ -362,29 +360,9 @@ namespace System.Net {
string h_name;
string[] h_aliases, h_addrlist;
#if TARGET_JVM
h_name = null;
h_aliases = null;
h_addrlist = null;
try {
java.net.InetAddress[] iaArr =
java.net.InetAddress.getAllByName(address);
if (iaArr != null && iaArr.Length > 0)
h_name = iaArr[0].getHostName();
if (iaArr != null && iaArr.Length > 0)
{
h_addrlist = new String[iaArr.Length];
for (int i = 0; i < h_addrlist.Length; i++)
h_addrlist[i] = iaArr[i].getHostAddress();
}
} catch (java.net.UnknownHostException jUHE) {
throw new SocketException((int)SocketError.HostNotFound, jUHE.Message);
}
#else
bool ret = GetHostByAddr_internal(address, out h_name, out h_aliases, out h_addrlist);
if (!ret)
Error_11001 (address);
#endif
return (hostent_to_IPHostEntry (address, h_name, h_aliases, h_addrlist));
}
@@ -437,26 +415,6 @@ namespace System.Net {
{
if (hostName == null)
throw new ArgumentNullException ("hostName");
#if TARGET_JVM
if (hostName.Length == 0)
hostName = "localhost";
try {
java.net.InetAddress[] iaArr = java.net.InetAddress.getAllByName(hostName);
IPHostEntry host = new IPHostEntry();
if (iaArr != null && iaArr.Length > 0)
{
host.HostName = iaArr[0].getHostName();
IPAddress[] ipArr = new IPAddress[iaArr.Length];
for (int i = 0; i < iaArr.Length; i++)
ipArr[i] = IPAddress.Parse(iaArr[i].getHostAddress());
host.AddressList = ipArr;
}
return host;
} catch (java.net.UnknownHostException jUHE) {
throw new SocketException((int)SocketError.HostNotFound, jUHE.Message);
}
#else
string h_name;
string[] h_aliases, h_addrlist;
@@ -465,14 +423,10 @@ namespace System.Net {
Error_11001 (hostName);
return(hostent_to_IPHostEntry(hostName, h_name, h_aliases, h_addrlist));
#endif
}
public static string GetHostName ()
{
#if TARGET_JVM
return java.net.InetAddress.getLocalHost ().getHostName ();
#else
string hostName;
bool ret = GetHostName_internal(out hostName);
@@ -481,7 +435,6 @@ namespace System.Net {
Error_11001 (hostName);
return hostName;
#endif
}
[Obsolete ("Use GetHostEntry instead")]

View File

@@ -145,11 +145,7 @@ namespace System.Net
((IDisposable) this).Dispose ();
}
#if TARGET_JVM //enable overrides for extenders
public override void Dispose()
#else
void IDisposable.Dispose()
#endif
{
Dispose (true);

View File

@@ -1165,10 +1165,7 @@ namespace System.Net
#endif
internal bool ChangeToSSLSocket (ref Stream stream) {
#if TARGET_JVM
stream.ChangeToSSLSocket ();
return true;
#elif SECURITY_DEP
#if SECURITY_DEP
SslStream sslStream = new SslStream (stream, true, callback, null);
//sslStream.AuthenticateAsClient (Host, this.ClientCertificates, SslProtocols.Default, false);
//TODO: client certificates

View File

@@ -32,6 +32,11 @@ using System.Collections.Specialized;
using System.IO;
using System.Security.Principal;
using System.Text;
#if NET_4_5
using System.Threading.Tasks;
using System.Net.WebSockets;
#endif
namespace System.Net {
public sealed class HttpListenerContext {
HttpListenerRequest request;
@@ -133,6 +138,23 @@ namespace System.Net {
return null;
}
}
#if NET_4_5
public Task<HttpListenerWebSocketContext> AcceptWebSocketAsync (string subProtocol)
{
throw new NotImplementedException ();
}
public Task<HttpListenerWebSocketContext> AcceptWebSocketAsync (string subProtocol, int receiveBufferSize, TimeSpan keepAliveInterval)
{
throw new NotImplementedException ();
}
public Task<HttpListenerWebSocketContext> AcceptWebSocketAsync (string subProtocol, int receiveBufferSize, TimeSpan keepAliveInterval, ArraySegment<byte> internalBuffer)
{
throw new NotImplementedException ();
}
#endif
}
}
#endif

View File

@@ -1315,11 +1315,7 @@ namespace System.Net {
// MS starts encoding with &# from 160 and stops at 255.
// We don't do that. One reason is the 65308/65310 unicode
// characters that look like '<' and '>'.
#if TARGET_JVM
if (c > 159 && c < 256) {
#else
if (c > 159) {
#endif
output.Append ("&#");
if (char.IsSurrogate (c))
output.Append (char.ConvertToUtf32 (s, i++));

View File

@@ -50,12 +50,10 @@ namespace System.Net
}
// Methods
#if !TARGET_JVM
void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)
{
base.GetObjectData (info, context);
}
#endif
public override void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)
{

View File

@@ -381,7 +381,6 @@ namespace System.Net
protocolVersion = version;
}
#if !TARGET_JVM
internal EventHandler SendRequest (HttpWebRequest request, string groupName)
{
WebConnection cnc;
@@ -399,7 +398,6 @@ namespace System.Net
return cnc.SendRequest (request);
}
#endif
public bool CloseConnectionGroup (string connectionGroupName)
{
lock (this) {

View File

@@ -137,11 +137,7 @@ namespace System.Net
private static bool _checkCRL = false;
private static SecurityProtocolType _securityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls;
#if TARGET_JVM
static bool expectContinue = false;
#else
static bool expectContinue = true;
#endif
static bool useNagle;
static RemoteCertificateValidationCallback server_cert_cb;
static bool tcp_keepalive;

View File

@@ -408,7 +408,7 @@ namespace System.Net
SetBusy ();
async = false;
WebRequest request = SetupRequest (address, method, true);
return request.GetRequestStream ();
return OpenWriteStream (request);
} catch (WebException) {
throw;
} catch (Exception ex) {
@@ -419,6 +419,15 @@ namespace System.Net
}
}
Stream OpenWriteStream (WebRequest request)
{
var stream = request.GetRequestStream ();
var wcs = stream as WebConnectionStream;
if (wcs != null)
wcs.GetResponseOnClose = true;
return stream;
}
private string DetermineMethod (Uri address, string method, bool is_upload)
{
if (method != null)
@@ -1268,7 +1277,7 @@ namespace System.Net
WebRequest request = null;
try {
request = SetupRequest ((Uri) args [0], (string) args [1], true);
Stream stream = request.GetRequestStream ();
var stream = OpenWriteStream (request);
OnOpenWriteCompleted (
new OpenWriteCompletedEventArgs (stream, null, false, args [2]));
} catch (ThreadInterruptedException){
@@ -1841,8 +1850,12 @@ namespace System.Net
try {
SetBusy ();
cts = new CancellationTokenSource ();
request = SetupRequest (address);
return await request.GetRequestStreamAsync ().ConfigureAwait (false);
request = await SetupRequestAsync (address, method, true).ConfigureAwait (false);
var stream = await request.GetRequestStreamAsync ();
var wcs = stream as WebConnectionStream;
if (wcs != null)
wcs.GetResponseOnClose = true;
return stream;
} catch (WebException) {
throw;
} catch (OperationCanceledException) {
@@ -2183,6 +2196,12 @@ namespace System.Net
if (data == null)
throw new ArgumentNullException ("data");
string cType = Headers ["Content-Type"];
if (cType != null && String.Compare (cType, urlEncodedCType, true) != 0)
throw new WebException ("Content-Type header cannot be changed from its default " +
"value for this request.");
Headers ["Content-Type"] = urlEncodedCType;
WebRequest request = null;
try {
SetBusy ();
@@ -2209,14 +2228,8 @@ namespace System.Net
CancellationToken token)
{
token.ThrowIfCancellationRequested ();
string cType = Headers ["Content-Type"];
if (cType != null && String.Compare (cType, urlEncodedCType, true) != 0)
throw new WebException ("Content-Type header cannot be changed from its default " +
"value for this request.");
WebResponse response = null;
Headers ["Content-Type"] = urlEncodedCType;
try {
MemoryStream tmpStream = new MemoryStream ();
foreach (string key in data) {

View File

@@ -490,11 +490,7 @@ namespace System.Net
if (e == null) { // At least we now where it comes from
try {
#if TARGET_JVM
throw new Exception ();
#else
throw new Exception (new System.Diagnostics.StackTrace ().ToString ());
#endif
} catch (Exception e2) {
e = e2;
}

View File

@@ -755,8 +755,22 @@ namespace System.Net
disposed = true;
}
internal bool GetResponseOnClose {
get; set;
}
public override void Close ()
{
if (GetResponseOnClose) {
if (disposed)
return;
disposed = true;
var response = (HttpWebResponse)request.GetResponse ();
response.ReadAll ();
response.Close ();
return;
}
if (sendChunked) {
if (disposed)
return;

View File

@@ -88,12 +88,10 @@ namespace System.Net
}
// Methods
#if !TARGET_JVM
void ISerializable.GetObjectData (SerializationInfo info, StreamingContext context)
{
base.GetObjectData (info, context);
}
#endif
public override void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)
{

View File

@@ -340,13 +340,11 @@ namespace System.Net
return sb.Append("\r\n").ToString();
}
#if !TARGET_JVM
void ISerializable.GetObjectData (SerializationInfo serializationInfo,
StreamingContext streamingContext)
{
GetObjectData (serializationInfo, streamingContext);
}
#endif
public override void GetObjectData (SerializationInfo serializationInfo, StreamingContext streamingContext)
{
int count = base.Count;

View File

@@ -106,9 +106,7 @@ namespace System.Net
{
throw new NotSupportedException ();
}
#if TARGET_JVM //enable overrides for extenders
public virtual void Dispose()
#elif NET_4_0
#if NET_4_0
public void Dispose ()
#else
void IDisposable.Dispose()