You've already forked linux-packaging-mono
Imported Upstream version 5.4.0.167
Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
parent
e49d6f06c0
commit
536cd135cc
@ -25,15 +25,13 @@
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#if SECURITY_DEP
|
||||
|
||||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using System.Runtime.InteropServices;
|
||||
namespace System.Net {
|
||||
class ChunkedInputStream : RequestStream {
|
||||
bool disposed;
|
||||
ChunkStream decoder;
|
||||
MonoChunkStream decoder;
|
||||
HttpListenerContext context;
|
||||
bool no_more_data;
|
||||
|
||||
@ -60,10 +58,10 @@ namespace System.Net {
|
||||
{
|
||||
this.context = context;
|
||||
WebHeaderCollection coll = (WebHeaderCollection) context.Request.Headers;
|
||||
decoder = new ChunkStream (coll);
|
||||
decoder = new MonoChunkStream (coll);
|
||||
}
|
||||
|
||||
public ChunkStream Decoder {
|
||||
public MonoChunkStream Decoder {
|
||||
get { return decoder; }
|
||||
set { decoder = value; }
|
||||
}
|
||||
@ -173,4 +171,3 @@ namespace System.Net {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -27,15 +27,6 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if SECURITY_DEP
|
||||
|
||||
#if MONO_SECURITY_ALIAS
|
||||
extern alias MonoSecurity;
|
||||
using MonoSecurity::Mono.Security.Authenticode;
|
||||
#else
|
||||
using Mono.Security.Authenticode;
|
||||
#endif
|
||||
|
||||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using System.Collections;
|
||||
@ -372,5 +363,4 @@ namespace System.Net {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -26,8 +26,6 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if SECURITY_DEP
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
namespace System.Net {
|
||||
@ -158,5 +156,4 @@ namespace System.Net {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -27,29 +27,17 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if SECURITY_DEP
|
||||
#if MONO_SECURITY_ALIAS
|
||||
extern alias MonoSecurity;
|
||||
#endif
|
||||
|
||||
#if MONO_SECURITY_ALIAS
|
||||
using MSI = MonoSecurity::Mono.Security.Interface;
|
||||
#else
|
||||
using MSI = Mono.Security.Interface;
|
||||
#endif
|
||||
|
||||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Net.Security;
|
||||
using System.Security.Authentication;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
using Mono.Net.Security;
|
||||
|
||||
namespace System.Net {
|
||||
sealed class HttpConnection
|
||||
{
|
||||
sealed class HttpConnection {
|
||||
static AsyncCallback onread_cb = new AsyncCallback (OnRead);
|
||||
const int BufferSize = 8192;
|
||||
Socket sock;
|
||||
@ -73,7 +61,7 @@ namespace System.Net {
|
||||
HttpListener last_listener;
|
||||
int [] client_cert_errors;
|
||||
X509Certificate2 client_cert;
|
||||
IMonoSslStream ssl_stream;
|
||||
SslStream ssl_stream;
|
||||
|
||||
public HttpConnection (Socket sock, EndPointListener epl, bool secure, X509Certificate cert)
|
||||
{
|
||||
@ -94,7 +82,7 @@ namespace System.Net {
|
||||
client_cert_errors = new int[] { (int)e };
|
||||
return true;
|
||||
});
|
||||
stream = ssl_stream.AuthenticatedStream;
|
||||
stream = ssl_stream;
|
||||
}
|
||||
timer = new Timer (OnTimeout, null, Timeout.Infinite, Timeout.Infinite);
|
||||
if (ssl_stream != null)
|
||||
@ -102,6 +90,10 @@ namespace System.Net {
|
||||
Init ();
|
||||
}
|
||||
|
||||
internal SslStream SslStream {
|
||||
get { return ssl_stream; }
|
||||
}
|
||||
|
||||
internal int [] ClientCertificateErrors {
|
||||
get { return client_cert_errors; }
|
||||
}
|
||||
@ -387,7 +379,7 @@ namespace System.Net {
|
||||
HttpListenerResponse response = context.Response;
|
||||
response.StatusCode = status;
|
||||
response.ContentType = "text/html";
|
||||
string description = HttpListenerResponseHelper.GetStatusDescription (status);
|
||||
string description = HttpStatusDescription.Get (status);
|
||||
string str;
|
||||
if (msg != null)
|
||||
str = String.Format ("<h1>{0} ({1})</h1>", description, msg);
|
||||
@ -491,5 +483,4 @@ namespace System.Net {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
112
mcs/class/System/System.Net/HttpListener.Mono.cs
Normal file
112
mcs/class/System/System.Net/HttpListener.Mono.cs
Normal file
@ -0,0 +1,112 @@
|
||||
//
|
||||
// HttpListener.Mono.cs
|
||||
//
|
||||
// Author:
|
||||
// Martin Baulig <mabaul@microsoft.com>
|
||||
//
|
||||
// Copyright (c) 2017 Xamarin Inc. (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
#if SECURITY_DEP
|
||||
#if MONO_SECURITY_ALIAS
|
||||
extern alias MonoSecurity;
|
||||
using MonoSecurity::Mono.Security.Authenticode;
|
||||
using MonoSecurity::Mono.Security.Interface;
|
||||
#else
|
||||
using Mono.Security.Authenticode;
|
||||
using Mono.Security.Interface;
|
||||
#endif
|
||||
using MNS = Mono.Net.Security;
|
||||
#endif
|
||||
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net.Security;
|
||||
using System.Security.Authentication.ExtendedProtection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
namespace System.Net {
|
||||
partial class HttpListener {
|
||||
#if SECURITY_DEP
|
||||
MonoTlsProvider tlsProvider;
|
||||
MonoTlsSettings tlsSettings;
|
||||
X509Certificate certificate;
|
||||
|
||||
internal HttpListener (X509Certificate certificate, MonoTlsProvider tlsProvider, MonoTlsSettings tlsSettings)
|
||||
: this ()
|
||||
{
|
||||
this.certificate = certificate;
|
||||
this.tlsProvider = tlsProvider;
|
||||
this.tlsSettings = tlsSettings;
|
||||
}
|
||||
#endif
|
||||
|
||||
internal X509Certificate LoadCertificateAndKey (IPAddress addr, int port)
|
||||
{
|
||||
#if SECURITY_DEP
|
||||
lock (_internalLock) {
|
||||
if (certificate != null)
|
||||
return certificate;
|
||||
|
||||
// Actually load the certificate
|
||||
try {
|
||||
string dirname = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData);
|
||||
string path = Path.Combine (dirname, ".mono");
|
||||
path = Path.Combine (path, "httplistener");
|
||||
string cert_file = Path.Combine (path, String.Format ("{0}.cer", port));
|
||||
if (!File.Exists (cert_file))
|
||||
return null;
|
||||
string pvk_file = Path.Combine (path, String.Format ("{0}.pvk", port));
|
||||
if (!File.Exists (pvk_file))
|
||||
return null;
|
||||
var cert = new X509Certificate2 (cert_file);
|
||||
cert.PrivateKey = PrivateKey.CreateFromFile (pvk_file).RSA;
|
||||
certificate = cert;
|
||||
return certificate;
|
||||
} catch {
|
||||
// ignore errors
|
||||
certificate = null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
#else
|
||||
throw new PlatformNotSupportedException ();
|
||||
#endif
|
||||
}
|
||||
|
||||
internal SslStream CreateSslStream (Stream innerStream, bool ownsStream, RemoteCertificateValidationCallback callback)
|
||||
{
|
||||
#if SECURITY_DEP
|
||||
lock (_internalLock) {
|
||||
if (tlsProvider == null)
|
||||
tlsProvider = MonoTlsProviderFactory.GetProvider ();
|
||||
var settings = (tlsSettings ?? MonoTlsSettings.DefaultSettings).Clone ();
|
||||
settings.RemoteCertificateValidationCallback = MNS.Private.CallbackHelpers.PublicToMono (callback);
|
||||
return new SslStream (innerStream, ownsStream, tlsProvider, settings);
|
||||
}
|
||||
#else
|
||||
throw new PlatformNotSupportedException ();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
@ -28,30 +28,18 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if SECURITY_DEP
|
||||
#if MONO_SECURITY_ALIAS
|
||||
extern alias MonoSecurity;
|
||||
using MonoSecurity::Mono.Security.Authenticode;
|
||||
using MSI = MonoSecurity::Mono.Security.Interface;
|
||||
#else
|
||||
using Mono.Security.Authenticode;
|
||||
using MSI = Mono.Security.Interface;
|
||||
#endif
|
||||
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net.Security;
|
||||
using System.Security.Authentication.ExtendedProtection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Security.Cryptography.X509Certificates;
|
||||
|
||||
using Mono.Net.Security;
|
||||
|
||||
|
||||
//TODO: logging
|
||||
namespace System.Net {
|
||||
public sealed class HttpListener : IDisposable {
|
||||
public sealed partial class HttpListener : IDisposable {
|
||||
AuthenticationSchemes auth_schemes;
|
||||
HttpListenerPrefixCollection prefixes;
|
||||
AuthenticationSchemeSelector auth_selector;
|
||||
@ -61,9 +49,7 @@ namespace System.Net {
|
||||
bool listening;
|
||||
bool disposed;
|
||||
|
||||
IMonoTlsProvider tlsProvider;
|
||||
MSI.MonoTlsSettings tlsSettings;
|
||||
X509Certificate certificate;
|
||||
readonly object _internalLock; // don't rename to match CoreFx
|
||||
|
||||
Hashtable registry; // Dictionary<HttpListenerContext,HttpListenerContext>
|
||||
ArrayList ctx_queue; // List<HttpListenerContext> ctx_queue;
|
||||
@ -78,6 +64,7 @@ namespace System.Net {
|
||||
|
||||
public HttpListener ()
|
||||
{
|
||||
_internalLock = new object ();
|
||||
prefixes = new HttpListenerPrefixCollection (this);
|
||||
registry = new Hashtable ();
|
||||
connections = Hashtable.Synchronized (new Hashtable ());
|
||||
@ -88,55 +75,6 @@ namespace System.Net {
|
||||
extendedProtectionPolicy = new ExtendedProtectionPolicy (PolicyEnforcement.Never);
|
||||
}
|
||||
|
||||
internal HttpListener (X509Certificate certificate, IMonoTlsProvider tlsProvider, MSI.MonoTlsSettings tlsSettings)
|
||||
: this ()
|
||||
{
|
||||
this.certificate = certificate;
|
||||
this.tlsProvider = tlsProvider;
|
||||
this.tlsSettings = tlsSettings;
|
||||
}
|
||||
|
||||
internal X509Certificate LoadCertificateAndKey (IPAddress addr, int port)
|
||||
{
|
||||
lock (registry) {
|
||||
if (certificate != null)
|
||||
return certificate;
|
||||
|
||||
// Actually load the certificate
|
||||
try {
|
||||
string dirname = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData);
|
||||
string path = Path.Combine (dirname, ".mono");
|
||||
path = Path.Combine (path, "httplistener");
|
||||
string cert_file = Path.Combine (path, String.Format ("{0}.cer", port));
|
||||
if (!File.Exists (cert_file))
|
||||
return null;
|
||||
string pvk_file = Path.Combine (path, String.Format ("{0}.pvk", port));
|
||||
if (!File.Exists (pvk_file))
|
||||
return null;
|
||||
var cert = new X509Certificate2 (cert_file);
|
||||
cert.PrivateKey = PrivateKey.CreateFromFile (pvk_file).RSA;
|
||||
certificate = cert;
|
||||
return certificate;
|
||||
} catch {
|
||||
// ignore errors
|
||||
certificate = null;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal IMonoSslStream CreateSslStream (Stream innerStream, bool ownsStream, MSI.MonoRemoteCertificateValidationCallback callback)
|
||||
{
|
||||
lock (registry) {
|
||||
if (tlsProvider == null)
|
||||
tlsProvider = MonoTlsProviderFactory.GetProviderInternal ();
|
||||
if (tlsSettings == null)
|
||||
tlsSettings = MSI.MonoTlsSettings.CopyDefaultSettings ();
|
||||
if (tlsSettings.RemoteCertificateValidationCallback == null)
|
||||
tlsSettings.RemoteCertificateValidationCallback = callback;
|
||||
return tlsProvider.CreateSslStream (innerStream, ownsStream, tlsSettings);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Digest, NTLM and Negotiate require ControlPrincipal
|
||||
public AuthenticationSchemes AuthenticationSchemes {
|
||||
@ -282,7 +220,7 @@ namespace System.Net {
|
||||
|
||||
void Cleanup (bool close_existing)
|
||||
{
|
||||
lock (registry) {
|
||||
lock (_internalLock) {
|
||||
if (close_existing) {
|
||||
// Need to copy this since closing will call UnregisterContext
|
||||
ICollection keys = registry.Keys;
|
||||
@ -438,7 +376,7 @@ namespace System.Net {
|
||||
|
||||
internal void RegisterContext (HttpListenerContext context)
|
||||
{
|
||||
lock (registry)
|
||||
lock (_internalLock)
|
||||
registry [context] = context;
|
||||
|
||||
ListenerAsyncResult ares = null;
|
||||
@ -457,7 +395,7 @@ namespace System.Net {
|
||||
|
||||
internal void UnregisterContext (HttpListenerContext context)
|
||||
{
|
||||
lock (registry)
|
||||
lock (_internalLock)
|
||||
registry.Remove (context);
|
||||
lock (ctx_queue) {
|
||||
int idx = ctx_queue.IndexOf (context);
|
||||
@ -477,11 +415,3 @@ namespace System.Net {
|
||||
}
|
||||
}
|
||||
}
|
||||
#else // SECURITY_DEP
|
||||
namespace System.Net
|
||||
{
|
||||
public sealed class HttpListener
|
||||
{
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -0,0 +1,42 @@
|
||||
//
|
||||
// HttpListenerBasicIdentity.platformnotsupported.cs
|
||||
//
|
||||
// Author:
|
||||
// Martin Baulig <mabaul@microsoft.com>
|
||||
//
|
||||
// Copyright (c) 2017 Xamarin Inc. (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
using System.Security.Principal;
|
||||
namespace System.Net {
|
||||
public class HttpListenerBasicIdentity : GenericIdentity {
|
||||
const string EXCEPTION_MESSAGE = "System.Net.HttpListenerBasicIdentity is not supported on the current platform.";
|
||||
|
||||
public HttpListenerBasicIdentity (string username, string password) : base (username, "Basic")
|
||||
{
|
||||
throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
|
||||
}
|
||||
|
||||
public virtual string Password {
|
||||
get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,8 +26,6 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if SECURITY_DEP
|
||||
|
||||
using System.Collections.Specialized;
|
||||
using System.IO;
|
||||
using System.Security.Principal;
|
||||
@ -162,5 +160,3 @@ namespace System.Net {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -25,19 +25,12 @@
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
#if SECURITY_DEP || EMBEDDED_IN_1_0
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
namespace System.Net {
|
||||
#if EMBEDDED_IN_1_0
|
||||
public class HttpListenerPrefixCollection : IEnumerable, ICollection {
|
||||
ArrayList prefixes;
|
||||
|
||||
#else
|
||||
public class HttpListenerPrefixCollection : ICollection<string>, IEnumerable<string>, IEnumerable {
|
||||
List<string> prefixes = new List<string> ();
|
||||
#endif
|
||||
HttpListener listener;
|
||||
|
||||
internal HttpListenerPrefixCollection (HttpListener listener)
|
||||
@ -95,12 +88,10 @@ namespace System.Net {
|
||||
((ICollection) prefixes).CopyTo (array, offset);
|
||||
}
|
||||
|
||||
#if !EMBEDDED_IN_1_0
|
||||
public IEnumerator<string> GetEnumerator ()
|
||||
{
|
||||
return prefixes.GetEnumerator ();
|
||||
}
|
||||
#endif
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator ()
|
||||
{
|
||||
@ -121,5 +112,4 @@ namespace System.Net {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -28,8 +28,6 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if SECURITY_DEP
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Specialized;
|
||||
using System.Globalization;
|
||||
@ -579,5 +577,4 @@ namespace System.Net {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -26,11 +26,10 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if SECURITY_DEP
|
||||
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace System.Net {
|
||||
public sealed class HttpListenerResponse : IDisposable
|
||||
{
|
||||
@ -218,7 +217,7 @@ namespace System.Net {
|
||||
if (value < 100 || value > 999)
|
||||
throw new ProtocolViolationException ("StatusCode must be between 100 and 999.");
|
||||
status_code = value;
|
||||
status_description = HttpListenerResponseHelper.GetStatusDescription (value);
|
||||
status_description = HttpStatusDescription.Get (value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -518,5 +517,4 @@ namespace System.Net {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -1,88 +0,0 @@
|
||||
//
|
||||
// System.Net.HttpListenerResponseHelper
|
||||
//
|
||||
// Author:
|
||||
// Gonzalo Paniagua Javier (gonzalo@novell.com)
|
||||
//
|
||||
// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
|
||||
// Copyright (C) 2016 Xamarin Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
namespace System.Net {
|
||||
// do not inline into HttpListenerResponse as this recursively brings everything that's
|
||||
// reachable by IDisposable.Dispose (and that's quite a lot in this case).
|
||||
static class HttpListenerResponseHelper {
|
||||
|
||||
internal static string GetStatusDescription (int code)
|
||||
{
|
||||
switch (code){
|
||||
case 100: return "Continue";
|
||||
case 101: return "Switching Protocols";
|
||||
case 102: return "Processing";
|
||||
case 200: return "OK";
|
||||
case 201: return "Created";
|
||||
case 202: return "Accepted";
|
||||
case 203: return "Non-Authoritative Information";
|
||||
case 204: return "No Content";
|
||||
case 205: return "Reset Content";
|
||||
case 206: return "Partial Content";
|
||||
case 207: return "Multi-Status";
|
||||
case 300: return "Multiple Choices";
|
||||
case 301: return "Moved Permanently";
|
||||
case 302: return "Found";
|
||||
case 303: return "See Other";
|
||||
case 304: return "Not Modified";
|
||||
case 305: return "Use Proxy";
|
||||
case 307: return "Temporary Redirect";
|
||||
case 400: return "Bad Request";
|
||||
case 401: return "Unauthorized";
|
||||
case 402: return "Payment Required";
|
||||
case 403: return "Forbidden";
|
||||
case 404: return "Not Found";
|
||||
case 405: return "Method Not Allowed";
|
||||
case 406: return "Not Acceptable";
|
||||
case 407: return "Proxy Authentication Required";
|
||||
case 408: return "Request Timeout";
|
||||
case 409: return "Conflict";
|
||||
case 410: return "Gone";
|
||||
case 411: return "Length Required";
|
||||
case 412: return "Precondition Failed";
|
||||
case 413: return "Request Entity Too Large";
|
||||
case 414: return "Request-Uri Too Long";
|
||||
case 415: return "Unsupported Media Type";
|
||||
case 416: return "Requested Range Not Satisfiable";
|
||||
case 417: return "Expectation Failed";
|
||||
case 422: return "Unprocessable Entity";
|
||||
case 423: return "Locked";
|
||||
case 424: return "Failed Dependency";
|
||||
case 500: return "Internal Server Error";
|
||||
case 501: return "Not Implemented";
|
||||
case 502: return "Bad Gateway";
|
||||
case 503: return "Service Unavailable";
|
||||
case 504: return "Gateway Timeout";
|
||||
case 505: return "Http Version Not Supported";
|
||||
case 507: return "Insufficient Storage";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
//
|
||||
// HttpListenerTimeoutManager.cs
|
||||
//
|
||||
// Authors:
|
||||
// Marek Safar <marek.safar@gmail.com>
|
||||
//
|
||||
// Copyright (C) 2015 Xamarin Inc (http://www.xamarin.com)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
namespace System.Net
|
||||
{
|
||||
public class HttpListenerTimeoutManager
|
||||
{
|
||||
internal const string EXCEPTION_MESSAGE = "System.Net.HttpListenerTimeoutManager is not supported on the current platform.";
|
||||
|
||||
public HttpListenerTimeoutManager ()
|
||||
{
|
||||
throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public TimeSpan EntityBody
|
||||
{
|
||||
get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
|
||||
set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public TimeSpan DrainEntityBody
|
||||
{
|
||||
get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
|
||||
set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public TimeSpan RequestQueue
|
||||
{
|
||||
get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
|
||||
set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public TimeSpan IdleConnection
|
||||
{
|
||||
get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
|
||||
set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public TimeSpan HeaderWait
|
||||
{
|
||||
get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
|
||||
set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
|
||||
}
|
||||
|
||||
[MonoTODO]
|
||||
public long MinSendBytesPerSecond
|
||||
{
|
||||
get { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
|
||||
set { throw new PlatformNotSupportedException (EXCEPTION_MESSAGE); }
|
||||
}
|
||||
}
|
||||
}
|
@ -112,8 +112,8 @@ namespace System.Net
|
||||
int maxResponseHeadersLength;
|
||||
static int defaultMaxResponseHeadersLength;
|
||||
int readWriteTimeout = 300000; // ms
|
||||
IMonoTlsProvider tlsProvider;
|
||||
#if SECURITY_DEP
|
||||
MonoTlsProvider tlsProvider;
|
||||
MonoTlsSettings tlsSettings;
|
||||
#endif
|
||||
ServerCertValidationCallback certValidationCallback;
|
||||
@ -161,7 +161,7 @@ namespace System.Net
|
||||
}
|
||||
|
||||
#if SECURITY_DEP
|
||||
internal HttpWebRequest (Uri uri, IMonoTlsProvider tlsProvider, MonoTlsSettings settings = null)
|
||||
internal HttpWebRequest (Uri uri, MonoTlsProvider tlsProvider, MonoTlsSettings settings = null)
|
||||
: this (uri)
|
||||
{
|
||||
this.tlsProvider = tlsProvider;
|
||||
@ -274,16 +274,16 @@ namespace System.Net
|
||||
}
|
||||
}
|
||||
|
||||
internal IMonoTlsProvider TlsProvider {
|
||||
#if SECURITY_DEP
|
||||
internal MonoTlsProvider TlsProvider {
|
||||
get { return tlsProvider; }
|
||||
}
|
||||
|
||||
#if SECURITY_DEP
|
||||
internal MonoTlsSettings TlsSettings {
|
||||
get { return tlsSettings; }
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
public X509CertificateCollection ClientCertificates {
|
||||
get {
|
||||
if (certificates == null)
|
||||
|
@ -48,7 +48,7 @@ namespace System.Net
|
||||
throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
|
||||
}
|
||||
|
||||
internal HttpWebRequest (Uri uri, object /* IMonoTlsProvider */ tlsProvider, object /* MonoTlsSettings */ settings = null)
|
||||
internal HttpWebRequest (Uri uri, object /* MonoTlsProvider */ tlsProvider, object /* MonoTlsSettings */ settings = null)
|
||||
{
|
||||
throw new PlatformNotSupportedException (EXCEPTION_MESSAGE);
|
||||
}
|
||||
|
@ -28,8 +28,6 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if SECURITY_DEP
|
||||
|
||||
using System.Threading;
|
||||
namespace System.Net {
|
||||
class ListenerAsyncResult : IAsyncResult {
|
||||
@ -181,5 +179,4 @@ namespace System.Net {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -27,8 +27,6 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if SECURITY_DEP
|
||||
|
||||
namespace System.Net {
|
||||
sealed class ListenerPrefix
|
||||
{
|
||||
@ -160,4 +158,3 @@ namespace System.Net {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -1341,4 +1341,54 @@ namespace Mono.Net
|
||||
}
|
||||
}
|
||||
|
||||
internal class CFDate : INativeObject, IDisposable {
|
||||
IntPtr handle;
|
||||
|
||||
internal CFDate (IntPtr handle, bool owns)
|
||||
{
|
||||
this.handle = handle;
|
||||
if (!owns)
|
||||
CFObject.CFRetain (handle);
|
||||
}
|
||||
|
||||
~CFDate ()
|
||||
{
|
||||
Dispose (false);
|
||||
}
|
||||
|
||||
[DllImport (CFObject.CoreFoundationLibrary)]
|
||||
extern static IntPtr CFDateCreate (IntPtr allocator, /* CFAbsoluteTime */ double at);
|
||||
|
||||
public static CFDate Create (DateTime date)
|
||||
{
|
||||
var referenceTime = new DateTime (2001, 1, 1);
|
||||
var difference = (date - referenceTime).TotalSeconds;
|
||||
var handle = CFDateCreate (IntPtr.Zero, difference);
|
||||
if (handle == IntPtr.Zero)
|
||||
throw new NotSupportedException ();
|
||||
return new CFDate (handle, true);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
//
|
||||
// System.Net.ChunkStream
|
||||
// System.Net.MonoChunkStream
|
||||
//
|
||||
// Authors:
|
||||
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
|
||||
@ -36,7 +36,7 @@ using System.Text;
|
||||
|
||||
namespace System.Net
|
||||
{
|
||||
class ChunkStream
|
||||
class MonoChunkStream
|
||||
{
|
||||
enum State {
|
||||
None,
|
||||
@ -76,13 +76,13 @@ namespace System.Net
|
||||
int trailerState;
|
||||
ArrayList chunks;
|
||||
|
||||
public ChunkStream (byte [] buffer, int offset, int size, WebHeaderCollection headers)
|
||||
public MonoChunkStream (byte [] buffer, int offset, int size, WebHeaderCollection headers)
|
||||
: this (headers)
|
||||
{
|
||||
Write (buffer, offset, size);
|
||||
}
|
||||
|
||||
public ChunkStream (WebHeaderCollection headers)
|
||||
public MonoChunkStream (WebHeaderCollection headers)
|
||||
{
|
||||
this.headers = headers;
|
||||
saved = new StringBuilder ();
|
@ -26,8 +26,6 @@
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
#if SECURITY_DEP
|
||||
|
||||
using System.IO;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
@ -248,5 +246,4 @@ namespace System.Net {
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user