Microsoft.Protocols.TestSuites.Common.MessageInspector.AddHeader C# (CSharp) Method

AddHeader() private method

This method is used to add headers to the MS-WOPI requests.
private AddHeader ( System &request, string headerKey, string value ) : void
request System Specify the request message which will be modified.
headerKey string Specify the http header key.
value string Specify the http header value.
return void
        private void AddHeader(ref System.ServiceModel.Channels.Message request, string headerKey, string value)
        {
            HttpRequestMessageProperty property;
            object propertyObject;

            if (request.Properties.TryGetValue(HttpRequestMessageProperty.Name, out propertyObject))
            {
                property = propertyObject as HttpRequestMessageProperty;
                if (!property.Headers.AllKeys.Contains(headerKey))
                {
                    property.Headers.Add(headerKey, value);
                }
            }
            else
            {
                HttpRequestMessageProperty messageProperty = new HttpRequestMessageProperty();
                request.Properties.Add(HttpRequestMessageProperty.Name, messageProperty);
                if (!messageProperty.Headers.AllKeys.Contains(headerKey))
                {
                    messageProperty.Headers.Add(headerKey, value);
                }
            }
        }
    }