You've already forked linux-packaging-mono
Imported Upstream version 5.0.0.42
Former-commit-id: fd56571888259555122d8a0f58c68838229cea2b
This commit is contained in:
parent
1190d13a04
commit
6bdd276d05
@ -295,10 +295,10 @@ namespace System.Net {
|
||||
|
||||
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
private extern static bool GetHostByName_internal(string host, out string h_name, out string[] h_aliases, out string[] h_addr_list);
|
||||
private extern static bool GetHostByName_internal(string host, out string h_name, out string[] h_aliases, out string[] h_addr_list, int hint);
|
||||
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
private extern static bool GetHostByAddr_internal(string addr, out string h_name, out string[] h_aliases, out string[] h_addr_list);
|
||||
private extern static bool GetHostByAddr_internal(string addr, out string h_name, out string[] h_aliases, out string[] h_addr_list, int hint);
|
||||
|
||||
[MethodImplAttribute(MethodImplOptions.InternalCall)]
|
||||
private extern static bool GetHostName_internal(out string h_name);
|
||||
@ -372,7 +372,7 @@ namespace System.Net {
|
||||
|
||||
string h_name;
|
||||
string[] h_aliases, h_addrlist;
|
||||
bool ret = GetHostByAddr_internal(address, out h_name, out h_aliases, out h_addrlist);
|
||||
bool ret = GetHostByAddr_internal(address, out h_name, out h_aliases, out h_addrlist, Socket.FamilyHint);
|
||||
if (!ret)
|
||||
Error_11001 (address);
|
||||
return (hostent_to_IPHostEntry (address, h_name, h_aliases, h_addrlist));
|
||||
@ -434,7 +434,7 @@ namespace System.Net {
|
||||
string h_name;
|
||||
string[] h_aliases, h_addrlist;
|
||||
|
||||
bool ret = GetHostByName_internal(hostName, out h_name, out h_aliases, out h_addrlist);
|
||||
bool ret = GetHostByName_internal(hostName, out h_name, out h_aliases, out h_addrlist, Socket.FamilyHint);
|
||||
if (ret == false)
|
||||
Error_11001 (hostName);
|
||||
|
||||
|
@ -46,10 +46,12 @@ namespace System.Net {
|
||||
set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
|
||||
}
|
||||
|
||||
#if SECURITY_DEP
|
||||
public AuthenticationSchemeSelector AuthenticationSchemeSelectorDelegate {
|
||||
get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
|
||||
set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
|
||||
}
|
||||
#endif
|
||||
|
||||
public bool IgnoreWriteExceptions {
|
||||
get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
|
||||
|
@ -49,7 +49,7 @@ namespace System.Net {
|
||||
public IPrincipal User {
|
||||
get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
|
||||
}
|
||||
|
||||
#if SECURITY_DEP
|
||||
public Task<HttpListenerWebSocketContext> AcceptWebSocketAsync (string subProtocol)
|
||||
{
|
||||
throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
|
||||
@ -69,5 +69,6 @@ namespace System.Net {
|
||||
{
|
||||
throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ namespace System.Net {
|
||||
return false;
|
||||
if (InputStream.EndRead (ares) <= 0)
|
||||
return true;
|
||||
} catch (ObjectDisposedException e) {
|
||||
} catch (ObjectDisposedException) {
|
||||
input_stream = null;
|
||||
return true;
|
||||
} catch {
|
||||
|
@ -225,7 +225,7 @@ namespace System.Net
|
||||
public string Server {
|
||||
get {
|
||||
CheckDisposed ();
|
||||
return webHeaders ["Server"];
|
||||
return webHeaders ["Server"] ?? "";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,10 +29,16 @@ using System.Net;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using ObjCRuntime;
|
||||
|
||||
namespace Mono.Net
|
||||
{
|
||||
internal class CFObject : IDisposable
|
||||
internal class CFType {
|
||||
[DllImport (CFObject.CoreFoundationLibrary, EntryPoint="CFGetTypeID")]
|
||||
public static extern IntPtr GetTypeID (IntPtr typeRef);
|
||||
}
|
||||
|
||||
internal class CFObject : IDisposable, INativeObject
|
||||
{
|
||||
public const string CoreFoundationLibrary = "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation";
|
||||
const string SystemLibrary = "/usr/lib/libSystem.dylib";
|
||||
@ -41,7 +47,7 @@ namespace Mono.Net
|
||||
public static extern IntPtr dlopen (string path, int mode);
|
||||
|
||||
[DllImport (SystemLibrary)]
|
||||
public static extern IntPtr dlsym (IntPtr handle, string symbol);
|
||||
static extern IntPtr dlsym (IntPtr handle, string symbol);
|
||||
|
||||
[DllImport (SystemLibrary)]
|
||||
public static extern void dlclose (IntPtr handle);
|
||||
@ -51,6 +57,25 @@ namespace Mono.Net
|
||||
return dlsym (handle, symbol);
|
||||
}
|
||||
|
||||
public static CFString GetStringConstant (IntPtr handle, string symbol)
|
||||
{
|
||||
var indirect = dlsym (handle, symbol);
|
||||
if (indirect == IntPtr.Zero)
|
||||
return null;
|
||||
var actual = Marshal.ReadIntPtr (indirect);
|
||||
if (actual == IntPtr.Zero)
|
||||
return null;
|
||||
return new CFString (actual, false);
|
||||
}
|
||||
|
||||
public static IntPtr GetIntPtr (IntPtr handle, string symbol)
|
||||
{
|
||||
var indirect = dlsym (handle, symbol);
|
||||
if (indirect == IntPtr.Zero)
|
||||
return IntPtr.Zero;
|
||||
return Marshal.ReadIntPtr (indirect);
|
||||
}
|
||||
|
||||
public static IntPtr GetCFObjectHandle (IntPtr handle, string symbol)
|
||||
{
|
||||
var indirect = dlsym (handle, symbol);
|
||||
@ -76,7 +101,7 @@ namespace Mono.Net
|
||||
public IntPtr Handle { get; private set; }
|
||||
|
||||
[DllImport (CoreFoundationLibrary)]
|
||||
extern static IntPtr CFRetain (IntPtr handle);
|
||||
internal extern static IntPtr CFRetain (IntPtr handle);
|
||||
|
||||
void Retain ()
|
||||
{
|
||||
@ -84,7 +109,7 @@ namespace Mono.Net
|
||||
}
|
||||
|
||||
[DllImport (CoreFoundationLibrary)]
|
||||
extern static void CFRelease (IntPtr handle);
|
||||
internal extern static void CFRelease (IntPtr handle);
|
||||
|
||||
void Release ()
|
||||
{
|
||||
@ -126,8 +151,22 @@ namespace Mono.Net
|
||||
dlclose (handle);
|
||||
}
|
||||
}
|
||||
|
||||
public static CFArray FromNativeObjects (params INativeObject[] values)
|
||||
{
|
||||
return new CFArray (Create (values), true);
|
||||
}
|
||||
|
||||
static unsafe CFArray Create (params IntPtr[] values)
|
||||
public static unsafe IntPtr Create (params IntPtr[] values)
|
||||
{
|
||||
if (values == null)
|
||||
throw new ArgumentNullException ("values");
|
||||
fixed (IntPtr* pv = values) {
|
||||
return CFArrayCreate (IntPtr.Zero, (IntPtr) pv, (IntPtr)values.Length, kCFTypeArrayCallbacks);
|
||||
}
|
||||
}
|
||||
|
||||
internal static unsafe CFArray CreateArray (params IntPtr[] values)
|
||||
{
|
||||
if (values == null)
|
||||
throw new ArgumentNullException ("values");
|
||||
@ -138,16 +177,19 @@ namespace Mono.Net
|
||||
return new CFArray (handle, false);
|
||||
}
|
||||
}
|
||||
|
||||
public static CFArray CreateArray (params INativeObject[] values)
|
||||
{
|
||||
return new CFArray (Create (values), true);
|
||||
}
|
||||
|
||||
public static CFArray Create (params CFObject[] values)
|
||||
public static IntPtr Create (params INativeObject[] values)
|
||||
{
|
||||
if (values == null)
|
||||
throw new ArgumentNullException ("values");
|
||||
|
||||
IntPtr[] _values = new IntPtr [values.Length];
|
||||
for (int i = 0; i < _values.Length; i++)
|
||||
_values[i] = values[i].Handle;
|
||||
|
||||
for (int i = 0; i < _values.Length; ++i)
|
||||
_values [i] = values [i].Handle;
|
||||
return Create (_values);
|
||||
}
|
||||
|
||||
@ -166,6 +208,20 @@ namespace Mono.Net
|
||||
return CFArrayGetValueAtIndex (Handle, (IntPtr) index);
|
||||
}
|
||||
}
|
||||
|
||||
static public T [] ArrayFromHandle<T> (IntPtr handle, Func<IntPtr, T> creation) where T : class, INativeObject
|
||||
{
|
||||
if (handle == IntPtr.Zero)
|
||||
return null;
|
||||
|
||||
var c = CFArrayGetCount (handle);
|
||||
T [] ret = new T [(int)c];
|
||||
|
||||
for (uint i = 0; i < (uint)c; i++) {
|
||||
ret [i] = creation (CFArrayGetValueAtIndex (handle, (IntPtr)i));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
internal class CFNumber : CFObject
|
||||
@ -209,6 +265,15 @@ namespace Mono.Net
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
[DllImport (CoreFoundationLibrary)]
|
||||
extern static IntPtr CFNumberCreate (IntPtr allocator, IntPtr theType, IntPtr valuePtr);
|
||||
|
||||
public static CFNumber FromInt32 (int number)
|
||||
{
|
||||
// 9 == kCFNumberIntType == C int
|
||||
return new CFNumber (CFNumberCreate (IntPtr.Zero, (IntPtr)9, (IntPtr)number), true);
|
||||
}
|
||||
|
||||
public static implicit operator int (CFNumber number)
|
||||
{
|
||||
@ -328,13 +393,105 @@ namespace Mono.Net
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
internal class CFData : CFObject
|
||||
{
|
||||
public CFData (IntPtr handle, bool own) : base (handle, own) { }
|
||||
|
||||
[DllImport (CoreFoundationLibrary)]
|
||||
extern static /* CFDataRef */ IntPtr CFDataCreate (/* CFAllocatorRef */ IntPtr allocator, /* UInt8* */ IntPtr bytes, /* CFIndex */ IntPtr length);
|
||||
public unsafe static CFData FromData (byte [] buffer)
|
||||
{
|
||||
fixed (byte* p = buffer)
|
||||
{
|
||||
return FromData ((IntPtr)p, (IntPtr)buffer.Length);
|
||||
}
|
||||
}
|
||||
|
||||
public static CFData FromData (IntPtr buffer, IntPtr length)
|
||||
{
|
||||
return new CFData (CFDataCreate (IntPtr.Zero, buffer, length), true);
|
||||
}
|
||||
|
||||
public IntPtr Length {
|
||||
get { return CFDataGetLength (Handle); }
|
||||
}
|
||||
|
||||
[DllImport (CoreFoundationLibrary)]
|
||||
extern static /* CFIndex */ IntPtr CFDataGetLength (/* CFDataRef */ IntPtr theData);
|
||||
|
||||
[DllImport (CoreFoundationLibrary)]
|
||||
extern static /* UInt8* */ IntPtr CFDataGetBytePtr (/* CFDataRef */ IntPtr theData);
|
||||
|
||||
/*
|
||||
* Exposes a read-only pointer to the underlying storage.
|
||||
*/
|
||||
public IntPtr Bytes {
|
||||
get { return CFDataGetBytePtr (Handle); }
|
||||
}
|
||||
|
||||
public byte this [long idx] {
|
||||
get {
|
||||
if (idx < 0 || (ulong) idx > (ulong) Length)
|
||||
throw new ArgumentException ("idx");
|
||||
return Marshal.ReadByte (new IntPtr (Bytes.ToInt64 () + idx));
|
||||
}
|
||||
|
||||
set {
|
||||
throw new NotImplementedException ("NSData arrays can not be modified, use an NSMutableData instead");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
internal class CFDictionary : CFObject
|
||||
{
|
||||
static readonly IntPtr KeyCallbacks;
|
||||
static readonly IntPtr ValueCallbacks;
|
||||
|
||||
static CFDictionary ()
|
||||
{
|
||||
var handle = dlopen (CoreFoundationLibrary, 0);
|
||||
if (handle == IntPtr.Zero)
|
||||
return;
|
||||
|
||||
try {
|
||||
KeyCallbacks = GetIndirect (handle, "kCFTypeDictionaryKeyCallBacks");
|
||||
ValueCallbacks = GetIndirect (handle, "kCFTypeDictionaryValueCallBacks");
|
||||
} finally {
|
||||
dlclose (handle);
|
||||
}
|
||||
}
|
||||
|
||||
public CFDictionary (IntPtr handle, bool own) : base (handle, own) { }
|
||||
|
||||
public static CFDictionary FromObjectAndKey (IntPtr obj, IntPtr key)
|
||||
{
|
||||
return new CFDictionary (CFDictionaryCreate (IntPtr.Zero, new IntPtr[] { key }, new IntPtr [] { obj }, (IntPtr)1, KeyCallbacks, ValueCallbacks), true);
|
||||
}
|
||||
|
||||
[DllImport (CoreFoundationLibrary)]
|
||||
extern static IntPtr CFDictionaryCreate (IntPtr allocator, IntPtr[] keys, IntPtr[] vals, IntPtr len, IntPtr keyCallbacks, IntPtr valCallbacks);
|
||||
|
||||
[DllImport (CoreFoundationLibrary)]
|
||||
extern static IntPtr CFDictionaryGetValue (IntPtr handle, IntPtr key);
|
||||
|
||||
[DllImport (CoreFoundationLibrary)]
|
||||
extern static IntPtr CFDictionaryCreateCopy (IntPtr allocator, IntPtr handle);
|
||||
|
||||
public CFDictionary Copy ()
|
||||
{
|
||||
return new CFDictionary (CFDictionaryCreateCopy (IntPtr.Zero, Handle), true);
|
||||
}
|
||||
|
||||
public CFMutableDictionary MutableCopy ()
|
||||
{
|
||||
return new CFMutableDictionary (CFDictionaryCreateMutableCopy (IntPtr.Zero, IntPtr.Zero, Handle), true);
|
||||
}
|
||||
|
||||
[DllImport (CoreFoundationLibrary)]
|
||||
extern static IntPtr CFDictionaryCreateMutableCopy (IntPtr allocator, IntPtr capacity, IntPtr theDict);
|
||||
|
||||
public IntPtr GetValue (IntPtr key)
|
||||
{
|
||||
return CFDictionaryGetValue (Handle, key);
|
||||
@ -346,6 +503,19 @@ namespace Mono.Net
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class CFMutableDictionary : CFDictionary
|
||||
{
|
||||
public CFMutableDictionary (IntPtr handle, bool own) : base (handle, own) { }
|
||||
|
||||
public void SetValue (IntPtr key, IntPtr val)
|
||||
{
|
||||
CFDictionarySetValue (Handle, key, val);
|
||||
}
|
||||
|
||||
[DllImport (CoreFoundationLibrary)]
|
||||
extern static void CFDictionarySetValue (IntPtr handle, IntPtr key, IntPtr val);
|
||||
}
|
||||
|
||||
internal class CFUrl : CFObject
|
||||
{
|
||||
@ -1066,4 +1236,86 @@ namespace Mono.Net
|
||||
return new CFWebProxy ();
|
||||
}
|
||||
}
|
||||
|
||||
class CFBoolean : INativeObject, IDisposable {
|
||||
IntPtr handle;
|
||||
|
||||
public static readonly CFBoolean True;
|
||||
public static readonly CFBoolean False;
|
||||
|
||||
static CFBoolean ()
|
||||
{
|
||||
var handle = CFObject.dlopen (CFObject.CoreFoundationLibrary, 0);
|
||||
if (handle == IntPtr.Zero)
|
||||
return;
|
||||
try {
|
||||
True = new CFBoolean (CFObject.GetCFObjectHandle (handle, "kCFBooleanTrue"), false);
|
||||
False = new CFBoolean (CFObject.GetCFObjectHandle (handle, "kCFBooleanFalse"), false);
|
||||
}
|
||||
finally {
|
||||
CFObject.dlclose (handle);
|
||||
}
|
||||
}
|
||||
|
||||
internal CFBoolean (IntPtr handle, bool owns)
|
||||
{
|
||||
this.handle = handle;
|
||||
if (!owns)
|
||||
CFObject.CFRetain (handle);
|
||||
}
|
||||
|
||||
~CFBoolean ()
|
||||
{
|
||||
Dispose (false);
|
||||
}
|
||||
|
||||
public IntPtr Handle {
|
||||
get {
|
||||
return handle;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose ()
|
||||
{
|
||||
Dispose (true);
|
||||
GC.SuppressFinalize (this);
|
||||
}
|
||||
|
||||
protected virtual void Dispose (bool disposing)
|
||||
{
|
||||
if (handle != IntPtr.Zero){
|
||||
CFObject.CFRelease (handle);
|
||||
handle = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
public static implicit operator bool (CFBoolean value)
|
||||
{
|
||||
return value.Value;
|
||||
}
|
||||
|
||||
public static explicit operator CFBoolean (bool value)
|
||||
{
|
||||
return FromBoolean (value);
|
||||
}
|
||||
|
||||
public static CFBoolean FromBoolean (bool value)
|
||||
{
|
||||
return value ? True : False;
|
||||
}
|
||||
|
||||
[DllImport (CFObject.CoreFoundationLibrary)]
|
||||
[return: MarshalAs (UnmanagedType.I1)]
|
||||
extern static /* Boolean */ bool CFBooleanGetValue (/* CFBooleanRef */ IntPtr boolean);
|
||||
|
||||
public bool Value {
|
||||
get {return CFBooleanGetValue (handle);}
|
||||
}
|
||||
|
||||
public static bool GetValue (IntPtr boolean)
|
||||
{
|
||||
return CFBooleanGetValue (boolean);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ namespace System.Net {
|
||||
InternalWrite (bytes, 0, bytes.Length);
|
||||
trailer_sent = true;
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException) {
|
||||
// Ignore error due to connection reset by peer
|
||||
}
|
||||
}
|
||||
@ -143,6 +143,8 @@ namespace System.Net {
|
||||
{
|
||||
if (disposed)
|
||||
throw new ObjectDisposedException (GetType ().ToString ());
|
||||
if (count == 0)
|
||||
return;
|
||||
|
||||
byte [] bytes = null;
|
||||
MemoryStream ms = GetHeaders (false);
|
||||
|
@ -158,7 +158,10 @@ namespace System.Net
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#pragma warning disable 618
|
||||
manager = (ConnectionManagementData) ConfigurationSettings.GetConfig (configKey);
|
||||
#pragma warning restore 618
|
||||
if (manager != null) {
|
||||
defaultConnectionLimit = (int) manager.GetMaxConnections ("*");
|
||||
}
|
||||
|
@ -83,7 +83,6 @@ namespace System.Net
|
||||
HttpWebRequest connect_request;
|
||||
|
||||
Exception connect_exception;
|
||||
static object classLock = new object ();
|
||||
MonoTlsStream tlsStream;
|
||||
|
||||
#if MONOTOUCH && !MONOTOUCH_TV && !MONOTOUCH_WATCH
|
||||
|
Reference in New Issue
Block a user