< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.HttpBindingBase
Assembly: CoreWCF.Http
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Http/src/CoreWCF/HttpBindingBase.cs
Line coverage
94%
Covered lines: 52
Uncovered lines: 3
Coverable lines: 55
Total lines: 194
Line coverage: 94.5%
Branch coverage
71%
Covered branches: 5
Total branches: 7
Branch coverage: 71.4%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor()100%11100%
GetTransport()80%5591.66%
SetReaderQuotas(...)100%11100%
CheckSettings()100%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Http/src/CoreWCF/HttpBindingBase.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System;
 5using System.ComponentModel;
 6using System.Net;
 7using System.Text;
 8using System.Xml;
 9using CoreWCF.Channels;
 10using CoreWCF.Runtime;
 11
 12namespace CoreWCF
 13{
 14    public abstract class HttpBindingBase : Binding
 15    {
 16        private readonly HttpTransportBindingElement _httpTransport;
 17        private readonly HttpsTransportBindingElement _httpsTransport;
 18
 34219        internal HttpBindingBase()
 20        {
 34221            _httpTransport = new HttpTransportBindingElement();
 34222            _httpsTransport = new HttpsTransportBindingElement();
 34223            TextMessageEncodingBindingElement = new TextMessageEncodingBindingElement
 34224            {
 34225                MessageVersion = MessageVersion.Soap11
 34226            };
 34227            MtomMessageEncodingBindingElement = new MtomMessageEncodingBindingElement
 34228            {
 34229                MessageVersion = MessageVersion.Soap11
 34230            };
 31
 34232            _httpsTransport.WebSocketSettings = _httpTransport.WebSocketSettings;
 34233        }
 34
 35        // [System.ComponentModel.DefaultValueAttribute(false)]
 36        // public bool AllowCookies { get { return default(bool); } set { } }
 37
 38        // [System.ComponentModel.DefaultValueAttribute((long)524288)]
 39        // public long MaxBufferPoolSize { get { return default(long); } set { } }
 40
 41        [DefaultValue(TransportDefaults.MaxReceivedMessageSize)]
 42        public long MaxReceivedMessageSize
 43        {
 44            get
 45            {
 646                return _httpTransport.MaxReceivedMessageSize;
 47            }
 48            set
 49            {
 1550                _httpTransport.MaxReceivedMessageSize = value;
 1551                _httpsTransport.MaxReceivedMessageSize = value;
 1552            }
 53        }
 54
 55        public int MaxBufferSize
 56        {
 657            get { return _httpTransport.MaxBufferSize; }
 58            set
 59            {
 1460                _httpTransport.MaxBufferSize = value;
 1461                _httpsTransport.MaxBufferSize = value;
 1462                MtomMessageEncodingBindingElement.MaxBufferSize = value;
 1463            }
 64        }
 65
 66        public XmlDictionaryReaderQuotas ReaderQuotas
 67        {
 68            get
 69            {
 270                return TextMessageEncodingBindingElement.ReaderQuotas;
 71            }
 72
 73            set
 74            {
 675                if (value == null)
 76                {
 077                    throw Fx.Exception.ArgumentNull(nameof(value));
 78                }
 79
 680                value.CopyTo(TextMessageEncodingBindingElement.ReaderQuotas);
 681                value.CopyTo(MtomMessageEncodingBindingElement.ReaderQuotas);
 82
 683                SetReaderQuotas(value);
 684            }
 85        }
 86
 118987        public override string Scheme { get { return GetTransport().Scheme; } }
 88
 89        public Encoding TextEncoding
 90        {
 91            get
 92            {
 093                return TextMessageEncodingBindingElement.WriteEncoding;
 94            }
 95
 96            set
 97            {
 698                TextMessageEncodingBindingElement.WriteEncoding = value;
 699                MtomMessageEncodingBindingElement.WriteEncoding = value;
 6100            }
 101        }
 102
 103        [DefaultValue(HttpTransportDefaults.TransferMode)]
 104        public TransferMode TransferMode
 105        {
 106            get
 107            {
 6108                return _httpTransport.TransferMode;
 109            }
 110
 111            set
 112            {
 17113                _httpTransport.TransferMode = value;
 17114                _httpsTransport.TransferMode = value;
 17115            }
 116        }
 117
 7102118        internal TextMessageEncodingBindingElement TextMessageEncodingBindingElement { get; }
 119
 3679120        internal MtomMessageEncodingBindingElement MtomMessageEncodingBindingElement { get; }
 121
 122        internal abstract BasicHttpSecurity BasicHttpSecurity
 123        {
 124            get;
 125        }
 126
 127        internal WebSocketTransportSettings InternalWebSocketSettings
 128        {
 129            get
 130            {
 62131                return _httpTransport.WebSocketSettings;
 132            }
 133        }
 134
 135        internal TransportBindingElement GetTransport()
 136        {
 137            Fx.Assert(BasicHttpSecurity != null, "this.BasicHttpSecurity should not return null from a derived class.");
 138
 4979139            BasicHttpSecurity basicHttpSecurity = BasicHttpSecurity;
 4979140            switch (basicHttpSecurity.Mode)
 141            {
 142                case BasicHttpSecurityMode.Message:
 0143                    throw new PlatformNotSupportedException(nameof(BasicHttpSecurityMode.Message));
 144                case BasicHttpSecurityMode.Transport:
 145                case BasicHttpSecurityMode.TransportWithMessageCredential:
 533146                    basicHttpSecurity.EnableTransportSecurity(_httpsTransport);
 533147                    basicHttpSecurity.ApplyAuthorizationPolicySupport(_httpsTransport);
 533148                    return _httpsTransport;
 149                case BasicHttpSecurityMode.TransportCredentialOnly:
 974150                    basicHttpSecurity.EnableTransportAuthentication(_httpTransport);
 974151                    basicHttpSecurity.ApplyAuthorizationPolicySupport(_httpTransport);
 974152                    return _httpTransport;
 153                default:
 154                    // ensure that there is no transport security
 3472155                    basicHttpSecurity.DisableTransportAuthentication(_httpTransport);
 3472156                    basicHttpSecurity.ApplyAuthorizationPolicySupport(_httpTransport);
 3472157                    return _httpTransport;
 158            }
 159        }
 160
 161        internal virtual void SetReaderQuotas(XmlDictionaryReaderQuotas readerQuotas)
 162        {
 4163        }
 164
 165        internal virtual void CheckSettings()
 166        {
 167            //BasicHttpSecurity security = this.BasicHttpSecurity;
 168            //if (security == null)
 169            //{
 170            //    return;
 171            //}
 172
 173            //BasicHttpSecurityMode mode = security.Mode;
 174            //if (mode == BasicHttpSecurityMode.None)
 175            //{
 176            //    return;
 177            //}
 178            //else if (mode == BasicHttpSecurityMode.Message || mode == BasicHttpSecurityMode.TransportWithMessageCreden
 179            //{
 180            //    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.Unsup
 181            //}
 182
 183            //// Transport.ClientCredentialType = InheritedFromHost are not supported.
 184            //Fx.Assert(
 185            //    (mode == BasicHttpSecurityMode.Transport) || (mode == BasicHttpSecurityMode.TransportCredentialOnly),
 186            //    "Unexpected BasicHttpSecurityMode value: " + mode);
 187            //HttpTransportSecurity transport = security.Transport;
 188            //if (transport != null && transport.ClientCredentialType == HttpClientCredentialType.InheritedFromHost)
 189            //{
 190            //    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotSupportedException(SR.Format(SR.Unsup
 191            //}
 3790192        }
 193    }
 194}