Fix S.SM.Http ref assembly for net8.0 (#5691)

* Fix S.SM.Http ref assembly for net8.0

Http ref assembly had been generated from netstandard dummy implementation instead of real implementation.

Some properties/methods/types shouldn't have been public so cleaned up in implementation so ref is correct

* Only add the placeholder files to suppress usage on other platforms when targeting netstandard and dotnet
This commit is contained in:
Matt Connew 2024-11-20 10:50:07 -08:00 коммит произвёл GitHub
Родитель 43b91dabd1
Коммит bed3c6a8a7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
15 изменённых файлов: 77 добавлений и 4820 удалений

Просмотреть файл

@ -52,6 +52,7 @@
<ItemGroup>
<None Include="$(PlaceholderFile)"
Pack="true"
Visible="false"
PackagePath="ref\netcoreapp2.0\;
$(BuildOutputTargetFolder)\MonoAndroid10\;
$(BuildOutputTargetFolder)\MonoTouch10\;
@ -59,6 +60,6 @@
$(BuildOutputTargetFolder)\xamarinmac20\;
$(BuildOutputTargetFolder)\xamarintvos10\;
$(BuildOutputTargetFolder)\xamarinwatchos10\"
Condition="$(TargetFrameworks.Contains('netstandard2.'))" />
Condition="$(TargetFrameworks.Contains('netstandard2.0')) and $(TargetFrameworks.Contains('$(DotNetVersion)'))" />
</ItemGroup>
</Project>

Просмотреть файл

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// GenAPI Version: 8.0.10.36005
// GenAPI Version: 10.0.11.5701
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -13,7 +13,7 @@ namespace System.ServiceModel
{
public BasicHttpBinding() { }
public BasicHttpBinding(System.ServiceModel.BasicHttpSecurityMode securityMode) { }
public System.ServiceModel.WSMessageEncoding MessageEncoding { get { throw null; } set { } }
public System.ServiceModel.WSMessageEncoding MessageEncoding { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
public System.ServiceModel.BasicHttpSecurity Security { get { throw null; } set { } }
public override System.ServiceModel.Channels.IChannelFactory<TChannel> BuildChannelFactory<TChannel>(System.ServiceModel.Channels.BindingParameterCollection parameters) { throw null; }
public override System.ServiceModel.Channels.BindingElementCollection CreateBindingElements() { throw null; }
@ -33,7 +33,7 @@ namespace System.ServiceModel
{
public BasicHttpsBinding() { }
public BasicHttpsBinding(System.ServiceModel.BasicHttpsSecurityMode securityMode) { }
public System.ServiceModel.WSMessageEncoding MessageEncoding { get { throw null; } set { } }
public System.ServiceModel.WSMessageEncoding MessageEncoding { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
public System.ServiceModel.BasicHttpsSecurity Security { get { throw null; } set { } }
public override System.ServiceModel.Channels.IChannelFactory<TChannel> BuildChannelFactory<TChannel>(System.ServiceModel.Channels.BindingParameterCollection parameters) { throw null; }
public override System.ServiceModel.Channels.BindingElementCollection CreateBindingElements() { throw null; }
@ -55,7 +55,7 @@ namespace System.ServiceModel
}
public sealed partial class BasicHttpsSecurity
{
internal BasicHttpsSecurity() { }
public BasicHttpsSecurity() { }
public System.ServiceModel.BasicHttpMessageSecurity Message { get { throw null; } set { } }
public System.ServiceModel.BasicHttpsSecurityMode Mode { get { throw null; } set { } }
public System.ServiceModel.HttpTransportSecurity Transport { get { throw null; } set { } }
@ -120,7 +120,7 @@ namespace System.ServiceModel
public MessageSecurityOverHttp() { }
public System.ServiceModel.Security.SecurityAlgorithmSuite AlgorithmSuite { get { throw null; } set { } }
public System.ServiceModel.MessageCredentialType ClientCredentialType { get { throw null; } set { } }
public bool NegotiateServiceCredential { get { throw null; } set { } }
public bool NegotiateServiceCredential { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
protected virtual bool IsSecureConversationEnabled() { throw null; }
}
public partial class NetHttpBinding : System.ServiceModel.HttpBindingBase
@ -128,10 +128,8 @@ namespace System.ServiceModel
public NetHttpBinding() { }
public NetHttpBinding(System.ServiceModel.BasicHttpSecurityMode securityMode) { }
public NetHttpBinding(System.ServiceModel.BasicHttpSecurityMode securityMode, bool reliableSessionEnabled) { }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public NetHttpBinding(string configurationName) { }
[System.ComponentModel.DefaultValueAttribute(System.ServiceModel.NetHttpMessageEncoding.Binary)]
public System.ServiceModel.NetHttpMessageEncoding MessageEncoding { get { throw null; } set { } }
public System.ServiceModel.NetHttpMessageEncoding MessageEncoding { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
public System.ServiceModel.OptionalReliableSession ReliableSession { get { throw null; } set { } }
public System.ServiceModel.BasicHttpSecurity Security { get { throw null; } set { } }
public System.ServiceModel.Channels.WebSocketTransportSettings WebSocketSettings { get { throw null; } }
@ -149,8 +147,7 @@ namespace System.ServiceModel
public NetHttpsBinding() { }
public NetHttpsBinding(System.ServiceModel.BasicHttpsSecurityMode securityMode) { }
public NetHttpsBinding(System.ServiceModel.BasicHttpsSecurityMode securityMode, bool reliableSessionEnabled) { }
[System.ComponentModel.DefaultValueAttribute(System.ServiceModel.NetHttpMessageEncoding.Binary)]
public System.ServiceModel.NetHttpMessageEncoding MessageEncoding { get { throw null; } set { } }
public System.ServiceModel.NetHttpMessageEncoding MessageEncoding { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
public System.ServiceModel.OptionalReliableSession ReliableSession { get { throw null; } set { } }
public System.ServiceModel.BasicHttpsSecurity Security { get { throw null; } set { } }
public System.ServiceModel.Channels.WebSocketTransportSettings WebSocketSettings { get { throw null; } }
@ -160,7 +157,7 @@ namespace System.ServiceModel
public sealed partial class NonDualMessageSecurityOverHttp : System.ServiceModel.MessageSecurityOverHttp
{
public NonDualMessageSecurityOverHttp() { }
public bool EstablishSecurityContext { get { throw null; } set { } }
public bool EstablishSecurityContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
protected override bool IsSecureConversationEnabled() { throw null; }
}
public partial class WS2007HttpBinding : System.ServiceModel.WSHttpBinding
@ -175,6 +172,7 @@ namespace System.ServiceModel
public WSHttpBinding() { }
public WSHttpBinding(System.ServiceModel.SecurityMode securityMode) { }
public WSHttpBinding(System.ServiceModel.SecurityMode securityMode, bool reliableSessionEnabled) { }
[System.ComponentModel.DefaultValueAttribute(false)]
public bool AllowCookies { get { throw null; } set { } }
public System.ServiceModel.WSHttpSecurity Security { get { throw null; } set { } }
public override System.ServiceModel.Channels.IChannelFactory<TChannel> BuildChannelFactory<TChannel>(System.ServiceModel.Channels.BindingParameterCollection parameters) { throw null; }
@ -186,17 +184,23 @@ namespace System.ServiceModel
{
protected WSHttpBindingBase() { }
protected WSHttpBindingBase(bool reliableSessionEnabled) { }
[System.ComponentModel.DefaultValueAttribute(false)]
public bool BypassProxyOnLocal { get { throw null; } set { } }
public System.ServiceModel.EnvelopeVersion EnvelopeVersion { get { throw null; } set { } }
public System.ServiceModel.EnvelopeVersion EnvelopeVersion { get { throw null; } }
[System.ComponentModel.DefaultValueAttribute((long)524288)]
public long MaxBufferPoolSize { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute((long)65536)]
public long MaxReceivedMessageSize { get { throw null; } set { } }
public System.ServiceModel.WSMessageEncoding MessageEncoding { get { throw null; } set { } }
public System.ServiceModel.WSMessageEncoding MessageEncoding { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
[System.ComponentModel.DefaultValueAttribute(null)]
public System.Uri ProxyAddress { get { throw null; } set { } }
public System.Xml.XmlDictionaryReaderQuotas ReaderQuotas { get { throw null; } set { } }
public System.ServiceModel.OptionalReliableSession ReliableSession { get { throw null; } set { } }
public override string Scheme { get { throw null; } }
public System.Text.Encoding TextEncoding { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(false)]
public bool TransactionFlow { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(true)]
public bool UseDefaultWebProxy { get { throw null; } set { } }
public override System.ServiceModel.Channels.BindingElementCollection CreateBindingElements() { throw null; }
protected abstract System.ServiceModel.Channels.SecurityBindingElement CreateMessageSecurity();
@ -231,6 +235,7 @@ namespace System.ServiceModel.Channels
{
public HttpResponseMessageProperty() { }
public System.Net.WebHeaderCollection Headers { get { throw null; } }
public System.Net.Http.HttpResponseMessage HttpResponseMessage { get { throw null; } }
public static string Name { get { throw null; } }
public System.Net.HttpStatusCode StatusCode { get { throw null; } set { } }
public string StatusDescription { get { throw null; } set { } }
@ -240,7 +245,8 @@ namespace System.ServiceModel.Channels
{
public HttpsTransportBindingElement() { }
protected HttpsTransportBindingElement(System.ServiceModel.Channels.HttpsTransportBindingElement elementToBeCloned) { }
public bool RequireClientCertificate { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(false)]
public bool RequireClientCertificate { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
public override string Scheme { get { throw null; } }
public override System.ServiceModel.Channels.IChannelFactory<TChannel> BuildChannelFactory<TChannel>(System.ServiceModel.Channels.BindingContext context) { throw null; }
public override System.ServiceModel.Channels.BindingElement Clone() { throw null; }
@ -251,22 +257,23 @@ namespace System.ServiceModel.Channels
public HttpTransportBindingElement() { }
protected HttpTransportBindingElement(System.ServiceModel.Channels.HttpTransportBindingElement elementToBeCloned) { }
[System.ComponentModel.DefaultValueAttribute(false)]
public bool AllowCookies { get { throw null; } set { } }
public bool AllowCookies { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
[System.ComponentModel.DefaultValueAttribute(System.Net.AuthenticationSchemes.Anonymous)]
public System.Net.AuthenticationSchemes AuthenticationScheme { get { throw null; } set { } }
public System.Net.AuthenticationSchemes AuthenticationScheme { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
[System.ComponentModel.DefaultValueAttribute(false)]
public bool BypassProxyOnLocal { get { throw null; } set { } }
public bool BypassProxyOnLocal { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
[System.ComponentModel.DefaultValueAttribute(true)]
public bool DecompressionEnabled { get { throw null; } set { } }
public bool DecompressionEnabled { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
public System.Security.Authentication.ExtendedProtection.ExtendedProtectionPolicy ExtendedProtectionPolicy { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(true)]
public bool KeepAliveEnabled { get { throw null; } set { } }
public bool KeepAliveEnabled { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
[System.ComponentModel.DefaultValueAttribute(65536)]
public int MaxBufferSize { get { throw null; } set { } }
public System.Net.IWebProxy Proxy { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(null)]
public System.Net.IWebProxy Proxy { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
[System.ComponentModel.DefaultValueAttribute(null)]
[System.ComponentModel.TypeConverterAttribute(typeof(System.UriTypeConverter))]
public System.Uri ProxyAddress { get { throw null; } set { } }
public System.Uri ProxyAddress { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
[System.ComponentModel.DefaultValueAttribute(System.Net.AuthenticationSchemes.Anonymous)]
public System.Net.AuthenticationSchemes ProxyAuthenticationScheme { get { throw null; } set { } }
public override string Scheme { get { throw null; } }
@ -286,10 +293,11 @@ namespace System.ServiceModel.Channels
}
public sealed partial class WebSocketTransportSettings : System.IEquatable<System.ServiceModel.Channels.WebSocketTransportSettings>
{
public const string BinaryEncoderTransferModeHeader = "microsoft-binary-transfer-mode";
public const string BinaryMessageReceivedAction = "http://schemas.microsoft.com/2011/02/websockets/onbinarymessage";
public const string SoapContentTypeHeader = "soap-content-type";
public const string TextMessageReceivedAction = "http://schemas.microsoft.com/2011/02/websockets/ontextmessage";
public WebSocketTransportSettings() { }
[System.ComponentModel.DefaultValueAttribute(false)]
public bool DisablePayloadMasking { get { throw null; } set { } }
[System.ComponentModel.DefaultValueAttribute(typeof(System.TimeSpan), "00:00:00")]
public System.TimeSpan KeepAliveInterval { get { throw null; } set { } }

Просмотреть файл

@ -1,192 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Globalization;
using System.Net.Http;
using System.Reflection;
using System.Runtime;
using System.Runtime.CompilerServices;
namespace System.ServiceModel.Channels
{
/// <summary>
/// Default HTTP message handler factory used by <see cref="HttpChannelListener"/> upon creation of an <see cref="HttpMessageHandler"/>
/// for instantiating a set of HTTP message handler types using their default constructors.
/// For more complex initialization scenarios, derive from <see cref="HttpMessageHandlerFactory"/>
/// and override the <see cref="OnCreate"/> method.
/// </summary>
public class HttpMessageHandlerFactory
{
private static readonly Type s_delegatingHandlerType = typeof(DelegatingHandler);
private Type[] _httpMessageHandlers;
private ConstructorInfo[] _handlerCtors;
private Func<IEnumerable<DelegatingHandler>> _handlerFunc;
/// <summary>
/// Initializes a new instance of the <see cref="HttpMessageHandlerFactory"/> class given
/// a set of HTTP message handler types to instantiate using their default constructors.
/// </summary>
/// <param name="handlers">An ordered list of HTTP message handler types to be invoked as part of an
/// <see cref="HttpMessageHandler"/> instance.
/// HTTP message handler types must derive from <see cref="DelegatingHandler"/> and have a public constructor
/// taking exactly one argument of type <see cref="HttpMessageHandler"/>. The handlers are invoked in a
/// bottom-up fashion in the incoming path and top-down in the outgoing path. That is, the last entry is called first
/// for an incoming request message but invoked last for an outgoing response message.</param>
[MethodImpl(MethodImplOptions.NoInlining)]
public HttpMessageHandlerFactory(params Type[] handlers)
{
if (handlers == null)
{
throw FxTrace.Exception.ArgumentNull("handlers");
}
if (handlers.Length == 0)
{
throw FxTrace.Exception.Argument("handlers", SR.InputTypeListEmptyError);
}
_handlerCtors = new ConstructorInfo[handlers.Length];
for (int cnt = 0; cnt < handlers.Length; cnt++)
{
Type handler = handlers[cnt];
if (handler == null)
{
throw FxTrace.Exception.Argument(
string.Format(CultureInfo.InvariantCulture, "handlers[<<{0}>>]", cnt),
SR.Format(SR.HttpMessageHandlerTypeNotSupported, "null", s_delegatingHandlerType.Name));
}
if (!s_delegatingHandlerType.IsAssignableFrom(handler) || handler.IsAbstract())
{
throw FxTrace.Exception.Argument(
string.Format(CultureInfo.InvariantCulture, "handlers[<<{0}>>]", cnt),
SR.Format(SR.HttpMessageHandlerTypeNotSupported, handler.Name, s_delegatingHandlerType.Name));
}
ConstructorInfo ctorInfo = handler.GetConstructor(Array.Empty<Type>());
_handlerCtors[cnt] = ctorInfo ?? throw FxTrace.Exception.Argument(
string.Format(CultureInfo.InvariantCulture, "handlers[<<{0}>>]", cnt),
SR.Format(SR.HttpMessageHandlerTypeNotSupported, handler.Name, s_delegatingHandlerType.Name));
}
_httpMessageHandlers = handlers;
}
/// <summary>
/// Initializes a new instance of the <see cref="HttpMessageHandlerFactory"/> class given
/// a function to create a set of <see cref="DelegatingHandler"/> instances.
/// </summary>
/// <param name="handlers">A function to generate an ordered list of <see cref="DelegatingHandler"/> instances
/// to be invoked as part of an <see cref="HttpMessageHandler"/> instance.
/// The handlers are invoked in a bottom-up fashion in the incoming path and top-down in the outgoing path. That is,
/// the last entry is called first for an incoming request message but invoked last for an outgoing response message.</param>
[MethodImpl(MethodImplOptions.NoInlining)]
public HttpMessageHandlerFactory(Func<IEnumerable<DelegatingHandler>> handlers)
{
_handlerFunc = handlers ?? throw FxTrace.Exception.ArgumentNull("handlers");
}
/// <summary>
/// Initializes a new instance of the <see cref="HttpMessageHandlerFactory"/> class.
/// </summary>
[MethodImpl(MethodImplOptions.NoInlining)]
protected HttpMessageHandlerFactory()
{
}
/// <summary>
/// Creates an instance of an <see cref="HttpMessageHandler"/> using the HTTP message handlers
/// provided in the constructor.
/// </summary>
/// <param name="innerChannel">The inner channel represents the destination of the HTTP message channel.</param>
/// <returns>The HTTP message channel.</returns>
[MethodImpl(MethodImplOptions.NoInlining)]
public HttpMessageHandler Create(HttpMessageHandler innerChannel)
{
if (innerChannel == null)
{
throw FxTrace.Exception.ArgumentNull("innerChannel");
}
return OnCreate(innerChannel);
}
/// <summary>
/// Creates an instance of an <see cref="HttpMessageHandler"/> using the HTTP message handlers
/// provided in the constructor.
/// </summary>
/// <param name="innerChannel">The inner channel represents the destination of the HTTP message channel.</param>
/// <returns>The HTTP message channel.</returns>
protected virtual HttpMessageHandler OnCreate(HttpMessageHandler innerChannel)
{
if (innerChannel == null)
{
throw FxTrace.Exception.ArgumentNull("innerChannel");
}
// Get handlers either by constructing types or by calling Func
IEnumerable<DelegatingHandler> handlerInstances = null;
try
{
if (_handlerFunc != null)
{
handlerInstances = _handlerFunc.Invoke();
if (handlerInstances != null)
{
foreach (DelegatingHandler handler in handlerInstances)
{
if (handler == null)
{
throw FxTrace.Exception.Argument("handlers", SR.Format(SR.DelegatingHandlerArrayFromFuncContainsNullItem, s_delegatingHandlerType.Name, GetFuncDetails(_handlerFunc)));
}
}
}
}
else if (_handlerCtors != null)
{
DelegatingHandler[] instances = new DelegatingHandler[_handlerCtors.Length];
for (int cnt = 0; cnt < _handlerCtors.Length; cnt++)
{
instances[cnt] = (DelegatingHandler)_handlerCtors[cnt].Invoke(Array.Empty<Type>());
}
handlerInstances = instances;
}
}
catch (TargetInvocationException targetInvocationException)
{
throw FxTrace.Exception.AsError(targetInvocationException);
}
// Wire handlers up
HttpMessageHandler pipeline = innerChannel;
if (handlerInstances != null)
{
foreach (DelegatingHandler handler in handlerInstances)
{
if (handler.InnerHandler != null)
{
throw FxTrace.Exception.Argument("handlers", SR.Format(SR.DelegatingHandlerArrayHasNonNullInnerHandler, s_delegatingHandlerType.Name, "InnerHandler", handler.GetType().Name));
}
handler.InnerHandler = pipeline;
pipeline = handler;
}
}
return pipeline;
}
private static string GetFuncDetails(Func<IEnumerable<DelegatingHandler>> func)
{
Fx.Assert(func != null, "Func should not be null.");
throw ExceptionHelper.PlatformNotSupported();
}
}
}

Просмотреть файл

@ -1,112 +0,0 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
namespace System.ServiceModel.Channels
{
public static class HttpRequestMessageExtensionMethods
{
private const string MessageHeadersPropertyKey = "System.ServiceModel.Channels.MessageHeaders";
internal static HashSet<string> WellKnownContentHeaders = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{ "Content-Disposition", "Content-Encoding", "Content-Language", "Content-Length", "Content-Location",
"Content-MD5", "Content-Range", "Content-Type", "Expires", "Last-Modified" };
internal static void AddHeaderWithoutValidation(this HttpHeaders httpHeaders, KeyValuePair<string, IEnumerable<string>> header)
{
Contract.Assert(httpHeaders != null, "httpHeaders should not be null.");
if (!httpHeaders.TryAddWithoutValidation(header.Key, header.Value))
{
throw FxTrace.Exception.AsError(new InvalidOperationException(SR.Format(
SR.CopyHttpHeaderFailed,
header.Key,
header.Value,
httpHeaders.GetType().Name)));
}
}
private static void CopyProperties(MessageProperties messageProperties, IDictionary<string, object> properties)
{
Contract.Assert(messageProperties != null, "The 'messageProperties' parameter should not be null.");
Contract.Assert(properties != null, "The 'properties' parameter should not be null.");
foreach (KeyValuePair<string, object> property in messageProperties)
{
object value = property.Value;
string key = property.Key;
if ((value is HttpRequestMessageProperty && string.Equals(key, HttpRequestMessageProperty.Name, StringComparison.OrdinalIgnoreCase)) ||
(value is HttpResponseMessageProperty && string.Equals(key, HttpResponseMessageProperty.Name, StringComparison.OrdinalIgnoreCase)))
{
continue;
}
properties[key] = value;
}
}
// We could potentially be passed an HttpRequestMessage without Content set. We presume that we have an HttpContent
// in many places so this ensures we have one and removes the need for special casing in many places.
public static bool CreateContentIfNull(this HttpRequestMessage httpRequestMessage)
{
Contract.Assert(httpRequestMessage != null, "The 'httpRequestMessage' parameter should never be null.");
if (httpRequestMessage.Content == null)
{
httpRequestMessage.Content = new ByteArrayContent(Array.Empty<byte>());
return true;
}
return false;
}
internal static void MergeWebHeaderCollection(this HttpRequestMessage requestMessage, WebHeaderCollection headersToMerge)
{
requestMessage.CreateContentIfNull();
MergeWebHeaderCollectionWithHttpHeaders(headersToMerge, requestMessage.Headers, requestMessage.Content.Headers);
}
internal static void MergeWebHeaderCollectionWithHttpHeaders(WebHeaderCollection headersToMerge, HttpHeaders mainHeaders, HttpHeaders contentHeaders)
{
foreach (string headerKey in headersToMerge.AllKeys)
{
if (WellKnownContentHeaders.Contains(headerKey))
{
contentHeaders.TryAddWithoutValidation(headerKey, headersToMerge[headerKey]);
}
else
{
mainHeaders.TryAddWithoutValidation(headerKey, headersToMerge[headerKey]);
}
}
}
internal static WebHeaderCollection ToWebHeaderCollection(this HttpRequestMessage httpRequest)
{
IEnumerable<KeyValuePair<string, IEnumerable<string>>> headers = httpRequest.Headers;
if (httpRequest.Content != null)
{
headers = headers.Concat(httpRequest.Content.Headers);
}
return headers.ToWebHeaderCollection();
}
internal static WebHeaderCollection ToWebHeaderCollection(this IEnumerable<KeyValuePair<string, IEnumerable<string>>> headers)
{
var webHeaders = new WebHeaderCollection();
foreach (var header in headers)
{
webHeaders[header.Key] = String.Join(",", header.Value);
}
return webHeaders;
}
}
}

Просмотреть файл

@ -2,37 +2,22 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Net;
using System.Net.Http;
namespace System.ServiceModel.Channels
{
public sealed class HttpRequestMessageProperty : IMessageProperty, IMergeEnabledMessageProperty
{
private TraditionalHttpRequestMessageProperty _traditionalProperty;
private HttpRequestMessageBackedProperty _httpBackedProperty;
private bool _initialCopyPerformed;
private bool _useHttpBackedProperty;
public HttpRequestMessageProperty()
{
_traditionalProperty = new TraditionalHttpRequestMessageProperty();
_useHttpBackedProperty = false;
}
internal HttpRequestMessageProperty(WebHeaderCollection originalHeaders)
{
_traditionalProperty = new TraditionalHttpRequestMessageProperty(originalHeaders);
_useHttpBackedProperty = false;
}
internal HttpRequestMessageProperty(HttpRequestMessage httpRequestMessage)
{
_httpBackedProperty = new HttpRequestMessageBackedProperty(httpRequestMessage);
_useHttpBackedProperty = true;
}
public static string Name
@ -44,9 +29,7 @@ namespace System.ServiceModel.Channels
{
get
{
return _useHttpBackedProperty ?
_httpBackedProperty.Headers :
_traditionalProperty.Headers;
return _traditionalProperty.Headers;
}
}
@ -54,9 +37,7 @@ namespace System.ServiceModel.Channels
{
get
{
return _useHttpBackedProperty ?
_httpBackedProperty.Method :
_traditionalProperty.Method;
return _traditionalProperty.Method;
}
set
@ -66,25 +47,13 @@ namespace System.ServiceModel.Channels
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value));
}
if (_useHttpBackedProperty)
{
_httpBackedProperty.Method = value;
}
else
{
_traditionalProperty.Method = value;
}
_traditionalProperty.Method = value;
}
}
public string QueryString
{
get
{
return _useHttpBackedProperty ?
_httpBackedProperty.QueryString :
_traditionalProperty.QueryString;
}
get => _traditionalProperty.QueryString;
set
{
@ -93,89 +62,27 @@ namespace System.ServiceModel.Channels
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value));
}
if (_useHttpBackedProperty)
{
_httpBackedProperty.QueryString = value;
}
else
{
_traditionalProperty.QueryString = value;
}
_traditionalProperty.QueryString = value;
}
}
public bool SuppressEntityBody
{
get
{
return _useHttpBackedProperty ?
_httpBackedProperty.SuppressEntityBody :
_traditionalProperty.SuppressEntityBody;
}
get => _traditionalProperty.SuppressEntityBody;
set
{
if (_useHttpBackedProperty)
{
_httpBackedProperty.SuppressEntityBody = value;
}
else
{
_traditionalProperty.SuppressEntityBody = value;
}
}
}
public HttpRequestMessage HttpRequestMessage
{
get
{
if (_useHttpBackedProperty)
{
return _httpBackedProperty.HttpRequestMessage;
}
return null;
_traditionalProperty.SuppressEntityBody = value;
}
}
IMessageProperty IMessageProperty.CreateCopy()
{
if (!_useHttpBackedProperty ||
!_initialCopyPerformed)
{
_initialCopyPerformed = true;
return this;
}
return _httpBackedProperty.CreateTraditionalRequestMessageProperty();
return this;
}
bool IMergeEnabledMessageProperty.TryMergeWithProperty(object propertyToMerge)
{
// The ImmutableDispatchRuntime will merge MessageProperty instances from the
// OperationContext (that were created before the response message was created) with
// MessageProperty instances on the message itself. The message's version of the
// HttpRequestMessageProperty may hold a reference to an HttpRequestMessage, and this
// cannot be discarded, so values from the OperationContext's property must be set on
// the message's version without completely replacing the message's property.
if (_useHttpBackedProperty)
{
HttpRequestMessageProperty requestProperty = propertyToMerge as HttpRequestMessageProperty;
if (requestProperty != null)
{
if (!requestProperty._useHttpBackedProperty)
{
_httpBackedProperty.MergeWithTraditionalProperty(requestProperty._traditionalProperty);
requestProperty._traditionalProperty = null;
requestProperty._httpBackedProperty = _httpBackedProperty;
requestProperty._useHttpBackedProperty = true;
}
return true;
}
}
return false;
}
@ -241,139 +148,5 @@ namespace System.ServiceModel.Channels
public bool SuppressEntityBody { get; set; }
}
private class HttpRequestMessageBackedProperty
{
public HttpRequestMessageBackedProperty(HttpRequestMessage httpRequestMessage)
{
Contract.Assert(httpRequestMessage != null, "The 'httpRequestMessage' property should never be null.");
HttpRequestMessage = httpRequestMessage;
}
public HttpRequestMessage HttpRequestMessage { get; private set; }
private WebHeaderCollection _headers;
public WebHeaderCollection Headers
{
get
{
if (_headers == null)
{
_headers = HttpRequestMessage.ToWebHeaderCollection();
}
return _headers;
}
}
public string Method
{
get
{
return HttpRequestMessage.Method.Method;
}
set
{
HttpRequestMessage.Method = new HttpMethod(value);
}
}
public string QueryString
{
get
{
string query = HttpRequestMessage.RequestUri.Query;
return query.Length > 0 ? query.Substring(1) : string.Empty;
}
set
{
UriBuilder uriBuilder = new UriBuilder(HttpRequestMessage.RequestUri);
uriBuilder.Query = value;
HttpRequestMessage.RequestUri = uriBuilder.Uri;
}
}
public bool SuppressEntityBody
{
get
{
HttpContent content = HttpRequestMessage.Content;
if (content != null)
{
long? contentLength = content.Headers.ContentLength;
if (!contentLength.HasValue ||
(contentLength.HasValue && contentLength.Value > 0))
{
return false;
}
}
return true;
}
set
{
HttpContent content = HttpRequestMessage.Content;
if (value && content != null &&
(!content.Headers.ContentLength.HasValue ||
content.Headers.ContentLength.Value > 0))
{
HttpContent newContent = new ByteArrayContent(Array.Empty<byte>());
foreach (KeyValuePair<string, IEnumerable<string>> header in content.Headers)
{
newContent.Headers.AddHeaderWithoutValidation(header);
}
HttpRequestMessage.Content = newContent;
content.Dispose();
}
else if (!value && content == null)
{
HttpRequestMessage.Content = new ByteArrayContent(Array.Empty<byte>());
}
}
}
public HttpRequestMessageProperty CreateTraditionalRequestMessageProperty()
{
HttpRequestMessageProperty copiedProperty = new HttpRequestMessageProperty();
foreach (var headerKey in Headers.AllKeys)
{
copiedProperty.Headers[headerKey] = Headers[headerKey];
}
if (Method != TraditionalHttpRequestMessageProperty.DefaultMethod)
{
copiedProperty.Method = Method;
}
copiedProperty.QueryString = QueryString;
copiedProperty.SuppressEntityBody = SuppressEntityBody;
return copiedProperty;
}
public void MergeWithTraditionalProperty(TraditionalHttpRequestMessageProperty propertyToMerge)
{
if (propertyToMerge.HasMethodBeenSet)
{
Method = propertyToMerge.Method;
}
if (propertyToMerge.QueryString != TraditionalHttpRequestMessageProperty.DefaultQueryString)
{
QueryString = propertyToMerge.QueryString;
}
SuppressEntityBody = propertyToMerge.SuppressEntityBody;
HttpRequestMessage.MergeWebHeaderCollection(propertyToMerge.Headers);
}
}
}
}

Просмотреть файл

@ -7,12 +7,17 @@ using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Runtime;
namespace System.ServiceModel.Channels
{
internal static class HttpResponseMessageExtensionMethods
{
internal static HashSet<string> s_wellKnownContentHeaders = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{ "Content-Disposition", "Content-Encoding", "Content-Language", "Content-Length", "Content-Location",
"Content-MD5", "Content-Range", "Content-Type", "Expires", "Last-Modified" };
// It is possible to receive an HttpResponseMessage without Content set from HttpClient. We presume that we have an HttpContent
// in many places so this ensures we have one and removes the need for special casing in many places.
internal static bool CreateContentIfNull(this HttpResponseMessage httpResponseMessage)
@ -31,7 +36,7 @@ namespace System.ServiceModel.Channels
internal static void MergeWebHeaderCollection(this HttpResponseMessage responseMessage, WebHeaderCollection headersToMerge)
{
responseMessage.CreateContentIfNull();
HttpRequestMessageExtensionMethods.MergeWebHeaderCollectionWithHttpHeaders(headersToMerge, responseMessage.Headers, responseMessage.Content.Headers);
MergeWebHeaderCollectionWithHttpHeaders(headersToMerge, responseMessage.Headers, responseMessage.Content.Headers);
}
internal static WebHeaderCollection ToWebHeaderCollection(this HttpResponseMessage httpResponse)
@ -43,5 +48,30 @@ namespace System.ServiceModel.Channels
}
return headers.ToWebHeaderCollection();
}
internal static void MergeWebHeaderCollectionWithHttpHeaders(WebHeaderCollection headersToMerge, HttpHeaders mainHeaders, HttpHeaders contentHeaders)
{
foreach (string headerKey in headersToMerge.AllKeys)
{
if (s_wellKnownContentHeaders.Contains(headerKey))
{
contentHeaders.TryAddWithoutValidation(headerKey, headersToMerge[headerKey]);
}
else
{
mainHeaders.TryAddWithoutValidation(headerKey, headersToMerge[headerKey]);
}
}
}
internal static WebHeaderCollection ToWebHeaderCollection(this IEnumerable<KeyValuePair<string, IEnumerable<string>>> headers)
{
var webHeaders = new WebHeaderCollection();
foreach (var header in headers)
{
webHeaders[header.Key] = String.Join(",", header.Value);
}
return webHeaders;
}
}
}

Просмотреть файл

@ -111,46 +111,6 @@ namespace System.ServiceModel.Channels
}
}
public bool SuppressEntityBody
{
get
{
return _useHttpBackedProperty ?
_httpBackedProperty.SuppressEntityBody :
_traditionalProperty.SuppressEntityBody;
}
set
{
if (_useHttpBackedProperty)
{
_httpBackedProperty.SuppressEntityBody = value;
}
else
{
_traditionalProperty.SuppressEntityBody = value;
}
}
}
public bool SuppressPreamble
{
get
{
return _useHttpBackedProperty ?
false :
_traditionalProperty.SuppressPreamble;
}
set
{
if (!_useHttpBackedProperty)
{
_traditionalProperty.SuppressPreamble = value;
}
}
}
public HttpResponseMessage HttpResponseMessage
{
get
@ -180,9 +140,9 @@ namespace System.ServiceModel.Channels
{
// The ImmutableDispatchRuntime will merge MessageProperty instances from the
// OperationContext (that were created before the response message was created) with
// MessageProperty instances on the message itself. The message's version of the
// HttpResponseMessageProperty may hold a reference to an HttpResponseMessage, and this
// cannot be discarded, so values from the OperationContext's property must be set on
// MessageProperty instances on the message itself. The message's version of the
// HttpResponseMessageProperty may hold a reference to an HttpResponseMessage, and this
// cannot be discarded, so values from the OperationContext's property must be set on
// the message's version without completely replacing the message's property.
if (_useHttpBackedProperty)
{
@ -263,10 +223,6 @@ namespace System.ServiceModel.Channels
public bool HasStatusCodeBeenSet { get; private set; }
public string StatusDescription { get; set; }
public bool SuppressEntityBody { get; set; }
public bool SuppressPreamble { get; set; }
}
private class HttpResponseMessageBackedProperty
@ -321,48 +277,6 @@ namespace System.ServiceModel.Channels
}
}
public bool SuppressEntityBody
{
get
{
HttpContent content = HttpResponseMessage.Content;
if (content != null)
{
long? contentLength = content.Headers.ContentLength;
if (!contentLength.HasValue ||
(contentLength.HasValue && contentLength.Value > 0))
{
return false;
}
}
return true;
}
set
{
HttpContent content = HttpResponseMessage.Content;
if (value && content != null &&
(!content.Headers.ContentLength.HasValue ||
content.Headers.ContentLength.Value > 0))
{
HttpContent newContent = new ByteArrayContent(Array.Empty<byte>());
foreach (KeyValuePair<string, IEnumerable<string>> header in content.Headers)
{
newContent.Headers.AddHeaderWithoutValidation(header);
}
HttpResponseMessage.Content = newContent;
content.Dispose();
}
else if (!value && content == null)
{
HttpResponseMessage.Content = new ByteArrayContent(Array.Empty<byte>());
}
}
}
public HttpResponseMessageProperty CreateTraditionalResponseMessageProperty()
{
HttpResponseMessageProperty copiedProperty = new HttpResponseMessageProperty();
@ -378,7 +292,6 @@ namespace System.ServiceModel.Channels
}
copiedProperty.StatusDescription = StatusDescription;
copiedProperty.SuppressEntityBody = SuppressEntityBody;
return copiedProperty;
}
@ -395,7 +308,6 @@ namespace System.ServiceModel.Channels
StatusDescription = propertyToMerge.StatusDescription;
}
SuppressEntityBody = propertyToMerge.SuppressEntityBody;
HttpResponseMessage.MergeWebHeaderCollection(propertyToMerge.Headers);
}
}

Просмотреть файл

@ -16,19 +16,15 @@ namespace System.ServiceModel.Channels
public class HttpTransportBindingElement
: TransportBindingElement
{
private HostNameComparisonMode _hostNameComparisonMode;
private bool _inheritBaseAddressSettings;
private int _maxBufferSize;
private bool _maxBufferSizeInitialized;
private string _method;
private AuthenticationSchemes _proxyAuthenticationScheme;
private string _realm;
private TimeSpan _requestInitializationTimeout;
private TransferMode _transferMode;
private bool _useDefaultWebProxy;
private WebSocketTransportSettings _webSocketSettings;
private ExtendedProtectionPolicy _extendedProtectionPolicy;
private int _maxPendingAccepts;
private MruCache<string, HttpClient> _httpClientCache;
public HttpTransportBindingElement()
@ -38,18 +34,13 @@ namespace System.ServiceModel.Channels
AuthenticationScheme = HttpTransportDefaults.AuthenticationScheme;
BypassProxyOnLocal = HttpTransportDefaults.BypassProxyOnLocal;
DecompressionEnabled = HttpTransportDefaults.DecompressionEnabled;
_hostNameComparisonMode = HttpTransportDefaults.HostNameComparisonMode;
KeepAliveEnabled = HttpTransportDefaults.KeepAliveEnabled;
_maxBufferSize = TransportDefaults.MaxBufferSize;
_maxPendingAccepts = HttpTransportDefaults.DefaultMaxPendingAccepts;
_method = string.Empty;
_proxyAuthenticationScheme = HttpTransportDefaults.ProxyAuthenticationScheme;
Proxy = HttpTransportDefaults.Proxy;
ProxyAddress = HttpTransportDefaults.ProxyAddress;
_realm = HttpTransportDefaults.Realm;
_requestInitializationTimeout = HttpTransportDefaults.RequestInitializationTimeout;
_transferMode = HttpTransportDefaults.TransferMode;
UnsafeConnectionNtlmAuthentication = HttpTransportDefaults.UnsafeConnectionNtlmAuthentication;
_useDefaultWebProxy = HttpTransportDefaults.UseDefaultWebProxy;
_webSocketSettings = HttpTransportDefaults.GetDefaultWebSocketTransportSettings();
}
@ -61,24 +52,18 @@ namespace System.ServiceModel.Channels
AuthenticationScheme = elementToBeCloned.AuthenticationScheme;
BypassProxyOnLocal = elementToBeCloned.BypassProxyOnLocal;
DecompressionEnabled = elementToBeCloned.DecompressionEnabled;
_hostNameComparisonMode = elementToBeCloned._hostNameComparisonMode;
_inheritBaseAddressSettings = elementToBeCloned.InheritBaseAddressSettings;
KeepAliveEnabled = elementToBeCloned.KeepAliveEnabled;
_maxBufferSize = elementToBeCloned._maxBufferSize;
_maxBufferSizeInitialized = elementToBeCloned._maxBufferSizeInitialized;
_maxPendingAccepts = elementToBeCloned._maxPendingAccepts;
_method = elementToBeCloned._method;
Proxy = elementToBeCloned.Proxy;
ProxyAddress = elementToBeCloned.ProxyAddress;
_proxyAuthenticationScheme = elementToBeCloned._proxyAuthenticationScheme;
_realm = elementToBeCloned._realm;
_requestInitializationTimeout = elementToBeCloned._requestInitializationTimeout;
_transferMode = elementToBeCloned._transferMode;
UnsafeConnectionNtlmAuthentication = elementToBeCloned.UnsafeConnectionNtlmAuthentication;
_useDefaultWebProxy = elementToBeCloned._useDefaultWebProxy;
_webSocketSettings = elementToBeCloned._webSocketSettings.Clone();
_extendedProtectionPolicy = elementToBeCloned.ExtendedProtectionPolicy;
MessageHandlerFactory = elementToBeCloned.MessageHandlerFactory;
}
[DefaultValue(HttpTransportDefaults.AllowCookies)]
@ -93,22 +78,6 @@ namespace System.ServiceModel.Channels
[DefaultValue(HttpTransportDefaults.DecompressionEnabled)]
public bool DecompressionEnabled { get; set; }
[DefaultValue(HttpTransportDefaults.HostNameComparisonMode)]
public HostNameComparisonMode HostNameComparisonMode
{
get
{
return _hostNameComparisonMode;
}
set
{
HostNameComparisonModeHelper.Validate(value);
_hostNameComparisonMode = value;
}
}
public HttpMessageHandlerFactory MessageHandlerFactory { get; set; }
public ExtendedProtectionPolicy ExtendedProtectionPolicy
{
get
@ -183,50 +152,10 @@ namespace System.ServiceModel.Channels
}
}
// server
[DefaultValue(HttpTransportDefaults.DefaultMaxPendingAccepts)]
public int MaxPendingAccepts
{
get
{
return _maxPendingAccepts;
}
set
{
if (value < 0)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value), value,
SR.ValueMustBeNonNegative));
}
if (value > HttpTransportDefaults.MaxPendingAcceptsUpperLimit)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value), value,
SR.Format(SR.HttpMaxPendingAcceptsTooLargeError, HttpTransportDefaults.MaxPendingAcceptsUpperLimit)));
}
_maxPendingAccepts = value;
}
}
// string.Empty == wildcard
internal string Method
{
get
{
return _method;
}
set
{
_method = value ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value));
}
}
// fully specified proxy by client
[DefaultValue(HttpTransportDefaults.Proxy)]
public IWebProxy Proxy { get; set; }
[DefaultValue(HttpTransportDefaults.ProxyAddress)]
[TypeConverter(typeof(UriTypeConverter))]
public Uri ProxyAddress { get; set; }
@ -251,41 +180,6 @@ namespace System.ServiceModel.Channels
}
}
[DefaultValue(HttpTransportDefaults.Realm)]
public string Realm
{
get
{
return _realm;
}
set
{
_realm = value ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(value));
}
}
[DefaultValue(typeof(TimeSpan), HttpTransportDefaults.RequestInitializationTimeoutString)]
public TimeSpan RequestInitializationTimeout
{
get
{
return _requestInitializationTimeout;
}
set
{
if (value < TimeSpan.Zero)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value), value, SR.SFxTimeoutOutOfRange0));
}
if (TimeoutHelper.IsTooLarge(value))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(value), value, SR.SFxTimeoutOutOfRangeTooBig));
}
_requestInitializationTimeout = value;
}
}
public override string Scheme { get { return "http"; } }
// client
@ -328,9 +222,6 @@ namespace System.ServiceModel.Channels
effectiveAuthenticationSchemes.IsNotSet(AuthenticationSchemes.Anonymous);
}
[DefaultValue(HttpTransportDefaults.UnsafeConnectionNtlmAuthentication)]
public bool UnsafeConnectionNtlmAuthentication { get; set; }
[DefaultValue(HttpTransportDefaults.UseDefaultWebProxy)]
public bool UseDefaultWebProxy
{
@ -440,11 +331,6 @@ namespace System.ServiceModel.Channels
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(context));
}
if (MessageHandlerFactory != null)
{
throw FxTrace.Exception.AsError(new InvalidOperationException(SR.Format(SR.HttpPipelineNotSupportedOnClientSide, "MessageHandlerFactory")));
}
if (!CanBuildChannelFactory<TChannel>(context))
{
Contract.Assert(context.Binding != null);
@ -493,11 +379,6 @@ namespace System.ServiceModel.Channels
return false;
}
if (_hostNameComparisonMode != http._hostNameComparisonMode)
{
return false;
}
if (_inheritBaseAddressSettings != http._inheritBaseAddressSettings)
{
return false;
@ -518,21 +399,11 @@ namespace System.ServiceModel.Channels
return false;
}
if (_realm != http._realm)
{
return false;
}
if (_transferMode != http._transferMode)
{
return false;
}
if (UnsafeConnectionNtlmAuthentication != http.UnsafeConnectionNtlmAuthentication)
{
return false;
}
if (_useDefaultWebProxy != http._useDefaultWebProxy)
{
return false;

Просмотреть файл

@ -13,24 +13,14 @@ namespace System.ServiceModel.Channels
internal const AuthenticationSchemes AuthenticationScheme = AuthenticationSchemes.Anonymous;
internal const bool BypassProxyOnLocal = false;
internal const bool DecompressionEnabled = true;
internal const HostNameComparisonMode HostNameComparisonMode = System.ServiceModel.HostNameComparisonMode.StrongWildcard;
internal const bool KeepAliveEnabled = true;
internal const IWebProxy Proxy = null;
internal const Uri ProxyAddress = null;
internal const AuthenticationSchemes ProxyAuthenticationScheme = AuthenticationSchemes.Anonymous;
internal const string Realm = "";
internal const TransferMode TransferMode = System.ServiceModel.TransferMode.Buffered;
internal const bool UnsafeConnectionNtlmAuthentication = false;
internal const bool UseDefaultWebProxy = true;
internal const string UpgradeHeader = "Upgrade";
internal const string ConnectionHeader = "Connection";
internal const HttpMessageHandlerFactory MessageHandlerFactory = null;
internal static TimeSpan RequestInitializationTimeout => TimeSpanHelper.FromMilliseconds(0, RequestInitializationTimeoutString);
internal const string RequestInitializationTimeoutString = "00:00:00";
internal const int DefaultMaxPendingAccepts = 0;
internal const int MaxPendingAcceptsUpperLimit = 100000;
internal static WebSocketTransportSettings GetDefaultWebSocketTransportSettings()
{

Просмотреть файл

@ -76,11 +76,6 @@ namespace System.ServiceModel.Channels
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(context));
}
if (MessageHandlerFactory != null)
{
throw FxTrace.Exception.AsError(new InvalidOperationException(SR.Format(SR.HttpPipelineNotSupportedOnClientSide, "MessageHandlerFactory")));
}
if (!CanBuildChannelFactory<TChannel>(context))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("TChannel", SR.Format(SR.ChannelTypeNotSupported, typeof(TChannel)));

Просмотреть файл

@ -11,7 +11,6 @@ namespace System.ServiceModel.Channels
{
public sealed class WebSocketTransportSettings : IEquatable<WebSocketTransportSettings>
{
public const string ConnectionOpenedAction = "http://schemas.microsoft.com/2011/02/session/onopen";
public const string BinaryMessageReceivedAction = "http://schemas.microsoft.com/2011/02/websockets/onbinarymessage";
public const string TextMessageReceivedAction = "http://schemas.microsoft.com/2011/02/websockets/ontextmessage";
public const string SoapContentTypeHeader = "soap-content-type";

Просмотреть файл

@ -60,21 +60,6 @@ namespace System.ServiceModel
}
}
[DefaultValue(HttpTransportDefaults.HostNameComparisonMode)]
public HostNameComparisonMode HostNameComparisonMode
{
get
{
return _httpTransport.HostNameComparisonMode;
}
set
{
_httpTransport.HostNameComparisonMode = value;
_httpsTransport.HostNameComparisonMode = value;
}
}
[DefaultValue(TransportDefaults.MaxBufferSize)]
public int MaxBufferSize
{

Просмотреть файл

@ -12,7 +12,6 @@ namespace System.ServiceModel
{
internal const HttpClientCredentialType DefaultClientCredentialType = HttpClientCredentialType.None;
internal const HttpProxyCredentialType DefaultProxyCredentialType = HttpProxyCredentialType.None;
internal const string DefaultRealm = HttpTransportDefaults.Realm;
private HttpClientCredentialType _clientCredentialType;
private HttpProxyCredentialType _proxyCredentialType;
@ -23,7 +22,6 @@ namespace System.ServiceModel
{
_clientCredentialType = DefaultClientCredentialType;
_proxyCredentialType = DefaultProxyCredentialType;
Realm = DefaultRealm;
_extendedProtectionPolicy = ExtendedProtectionPolicyHelper.DefaultPolicy;
}
@ -55,8 +53,6 @@ namespace System.ServiceModel
}
}
public string Realm { get; set; }
public ExtendedProtectionPolicy ExtendedProtectionPolicy
{
get
@ -91,7 +87,6 @@ namespace System.ServiceModel
{
http.AuthenticationScheme = HttpClientCredentialTypeHelper.MapToAuthenticationScheme(_clientCredentialType);
http.ProxyAuthenticationScheme = HttpProxyCredentialTypeHelper.MapToAuthenticationScheme(_proxyCredentialType);
http.Realm = Realm;
http.ExtendedProtectionPolicy = ExtendedProtectionPolicy;
}
@ -99,14 +94,12 @@ namespace System.ServiceModel
{
transportSecurity._clientCredentialType = HttpClientCredentialTypeHelper.MapToClientCredentialType(http.AuthenticationScheme);
transportSecurity._proxyCredentialType = HttpProxyCredentialTypeHelper.MapToProxyCredentialType(http.ProxyAuthenticationScheme);
transportSecurity.Realm = http.Realm;
transportSecurity._extendedProtectionPolicy = http.ExtendedProtectionPolicy;
}
private void DisableAuthentication(HttpTransportBindingElement http)
{
http.AuthenticationScheme = AuthenticationSchemes.Anonymous;
http.Realm = DefaultRealm;
//ExtendedProtectionPolicy is always copied - even for security mode None, Message and TransportWithMessageCredential,
//because the settings for ExtendedProtectionPolicy are always below the <security><transport> element
//http.ExtendedProtectionPolicy = this.extendedProtectionPolicy;
@ -114,7 +107,7 @@ namespace System.ServiceModel
private static bool IsDisabledAuthentication(HttpTransportBindingElement http)
{
return http.AuthenticationScheme == AuthenticationSchemes.Anonymous && http.Realm == DefaultRealm;
return http.AuthenticationScheme == AuthenticationSchemes.Anonymous;
}
internal void ConfigureTransportProtectionAndAuthentication(HttpsTransportBindingElement https)
@ -123,7 +116,7 @@ namespace System.ServiceModel
https.RequireClientCertificate = (_clientCredentialType == HttpClientCredentialType.Certificate);
}
public static void ConfigureTransportProtectionAndAuthentication(HttpsTransportBindingElement https, HttpTransportSecurity transportSecurity)
internal static void ConfigureTransportProtectionAndAuthentication(HttpsTransportBindingElement https, HttpTransportSecurity transportSecurity)
{
ConfigureAuthentication(https, transportSecurity);
if (https.RequireClientCertificate)

Просмотреть файл

@ -149,7 +149,6 @@ namespace System.ServiceModel
protected WSHttpBindingBase(bool reliableSessionEnabled) { }
public bool BypassProxyOnLocal { get { return default; } set { } }
public bool TransactionFlow { get { return default; } set { } }
//public System.ServiceModel.HostNameComparisonMode HostNameComparisonMode { get { return default; } set { } }
public long MaxBufferPoolSize { get { return default; } set { } }
public long MaxReceivedMessageSize { get { return default; } set { } }
public System.ServiceModel.WSMessageEncoding MessageEncoding { get { return default; } set { } }

Разница между файлами не показана из-за своего большого размера Загрузить разницу