diff options
author | Martin Baulig <martin.baulig@xamarin.com> | 2013-06-24 20:30:40 +0400 |
---|---|---|
committer | Martin Baulig <martin.baulig@xamarin.com> | 2013-06-24 20:30:40 +0400 |
commit | 3813ebc551efb505866ac1d2116753fd51da9e84 (patch) | |
tree | 6a25221d8f9efd80c8246e14df1503abb7b5b09e /mcs/class/System.Net.Http.WebRequest | |
parent | 1b5ef4d3df262c66f58596bda152db5f4c34741c (diff) |
Implement System.Net.Http.WebRequestHandler.
Diffstat (limited to 'mcs/class/System.Net.Http.WebRequest')
3 files changed, 216 insertions, 0 deletions
diff --git a/mcs/class/System.Net.Http.WebRequest/Assembly/AssemblyInfo.cs b/mcs/class/System.Net.Http.WebRequest/Assembly/AssemblyInfo.cs new file mode 100644 index 00000000000..c74c9c9e66b --- /dev/null +++ b/mcs/class/System.Net.Http.WebRequest/Assembly/AssemblyInfo.cs @@ -0,0 +1,58 @@ +// +// AssemblyInfo.cs +// +// Author: +// Martin Baulig <martin.baulig@xamarin.com> +// +// Copyright (c) 2013 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; +using System.Reflection; +using System.Resources; +using System.Security; +using System.Security.Permissions; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle ("System.Net.Http.WebRequest.dll")] +[assembly: AssemblyDescription ("System.Net.Http.WebRequest.dll")] +[assembly: AssemblyDefaultAlias ("System.Net.Http.WebRequest.dll")] + +[assembly: AssemblyCompany (Consts.MonoCompany)] +[assembly: AssemblyProduct (Consts.MonoProduct)] +[assembly: AssemblyCopyright (Consts.MonoCopyright)] +[assembly: AssemblyVersion (Consts.FxVersion)] +[assembly: SatelliteContractVersion (Consts.FxVersion)] +[assembly: AssemblyInformationalVersion (Consts.FxFileVersion)] +[assembly: AssemblyFileVersion (Consts.FxFileVersion)] + +[assembly: NeutralResourcesLanguage ("en-US")] +[assembly: CLSCompliant (true)] +[assembly: AssemblyDelaySign (true)] + +[assembly: AssemblyKeyFile ("../../msfinal.pub")] + +[assembly: ComVisible (false)] + diff --git a/mcs/class/System.Net.Http.WebRequest/System.Net.Http.WebRequest.dll.sources b/mcs/class/System.Net.Http.WebRequest/System.Net.Http.WebRequest.dll.sources new file mode 100644 index 00000000000..ea3f5d04c53 --- /dev/null +++ b/mcs/class/System.Net.Http.WebRequest/System.Net.Http.WebRequest.dll.sources @@ -0,0 +1,4 @@ +../../build/common/Consts.cs +../../build/common/MonoTODOAttribute.cs +Assembly/AssemblyInfo.cs +System.Net.Http.WebRequest/WebRequestHandler.cs diff --git a/mcs/class/System.Net.Http.WebRequest/System.Net.Http.WebRequest/WebRequestHandler.cs b/mcs/class/System.Net.Http.WebRequest/System.Net.Http.WebRequest/WebRequestHandler.cs new file mode 100644 index 00000000000..b19e6b85885 --- /dev/null +++ b/mcs/class/System.Net.Http.WebRequest/System.Net.Http.WebRequest/WebRequestHandler.cs @@ -0,0 +1,154 @@ +// +// WebRequestHandler.cs +// +// Author: +// Martin Baulig <martin.baulig@xamarin.com> +// +// Copyright (c) 2013 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; +using System.Net.Cache; +using System.Net.Security; +using System.Security.Principal; +using System.Security.Cryptography.X509Certificates; + +namespace System.Net.Http +{ + public class WebRequestHandler : HttpClientHandler + { + bool allowPipelining; + RequestCachePolicy cachePolicy; + AuthenticationLevel authenticationLevel; + TimeSpan continueTimeout; + TokenImpersonationLevel impersonationLevel; + int maxResponseHeadersLength; + int readWriteTimeout; + RemoteCertificateValidationCallback serverCertificateValidationCallback; + bool unsafeAuthenticatedConnectionSharing; + + public WebRequestHandler () + { + allowPipelining = true; + authenticationLevel = AuthenticationLevel.MutualAuthRequested; + cachePolicy = System.Net.WebRequest.DefaultCachePolicy; + continueTimeout = TimeSpan.FromMilliseconds (350); + impersonationLevel = TokenImpersonationLevel.Delegation; + maxResponseHeadersLength = HttpWebRequest.DefaultMaximumResponseHeadersLength; + readWriteTimeout = 300000; + serverCertificateValidationCallback = null; + unsafeAuthenticatedConnectionSharing = false; + } + + public bool AllowPipelining { + get { return allowPipelining; } + set { + EnsureModifiability (); + allowPipelining = value; + } + } + + public RequestCachePolicy CachePolicy { + get { return cachePolicy; } + set { + EnsureModifiability (); + cachePolicy = value; + } + } + + public AuthenticationLevel AuthenticationLevel { + get { return authenticationLevel; } + set { + EnsureModifiability (); + authenticationLevel = value; + } + } + + [MonoTODO] + public X509CertificateCollection ClientCertificates { + get { throw new NotImplementedException (); } + } + + [MonoTODO] + public TimeSpan ContinueTimeout { + get { return continueTimeout; } + set { + EnsureModifiability (); + continueTimeout = value; + } + } + + public TokenImpersonationLevel ImpersonationLevel { + get { return impersonationLevel; } + set { + EnsureModifiability (); + impersonationLevel = value; + } + } + + public int MaxResponseHeadersLength { + get { return maxResponseHeadersLength; } + set { + EnsureModifiability (); + maxResponseHeadersLength = value; + } + } + + public int ReadWriteTimeout { + get { return readWriteTimeout; } + set { + EnsureModifiability (); + readWriteTimeout = value; + } + } + + [MonoTODO] + public RemoteCertificateValidationCallback ServerCertificateValidationCallback { + get { return serverCertificateValidationCallback; } + set { + EnsureModifiability (); + serverCertificateValidationCallback = value; + } + } + + public bool UnsafeAuthenticatedConnectionSharing { + get { return unsafeAuthenticatedConnectionSharing; } + set { + EnsureModifiability (); + unsafeAuthenticatedConnectionSharing = value; + } + } + + internal override HttpWebRequest CreateWebRequest (HttpRequestMessage request) + { + HttpWebRequest wr = base.CreateWebRequest (request); + + wr.Pipelined = allowPipelining; + wr.AuthenticationLevel = authenticationLevel; + wr.CachePolicy = cachePolicy; + wr.ImpersonationLevel = impersonationLevel; + wr.MaximumResponseHeadersLength = maxResponseHeadersLength; + wr.ReadWriteTimeout = readWriteTimeout; + wr.UnsafeAuthenticatedConnectionSharing = unsafeAuthenticatedConnectionSharing; + + return wr; + } + } +} + |