Microsoft.Protocols.TestSuites.MS_OXCMAPIHTTP.AdapterHelper.InitializeHTTPHeader C# (CSharp) Method

InitializeHTTPHeader() public static method

Initialize HTTP Header
public static InitializeHTTPHeader ( RequestType requestType, string clientInstance, int counter ) : WebHeaderCollection
requestType RequestType The request type
clientInstance string The string of the client instance
counter int The counter
return System.Net.WebHeaderCollection
        public static WebHeaderCollection InitializeHTTPHeader(RequestType requestType, string clientInstance, int counter)
        {
            WebHeaderCollection webHeaderCollection = new WebHeaderCollection();
            webHeaderCollection.Add("X-ClientInfo", ConstValues.ClientInfo);
            webHeaderCollection.Add("X-RequestId", clientInstance + ":" + counter.ToString());
            webHeaderCollection.Add("X-ClientApplication", ConstValues.ClientApplication);
            webHeaderCollection.Add("X-RequestType", requestType.ToString());
            return webHeaderCollection;
        }

Usage Example

        /// <summary>
        /// Send the request to address book server endpoint.
        /// </summary>
        /// <param name="requestBody">The request body.</param>
        /// <param name="requestType">The type of the request.</param>
        /// <param name="cookieChange">If the session context cookie changed.</param>
        /// <returns>The common response.</returns>
        private CommonResponse SendAddressBookRequest(IRequestBody requestBody, RequestType requestType, bool cookieChange = true)
        {
            byte[]              rawBuffer;
            CommonResponse      commonResponse      = null;
            WebHeaderCollection webHeaderCollection = AdapterHelper.InitializeHTTPHeader(requestType, AdapterHelper.ClientInstance, AdapterHelper.Counter);

            // Send the Execute HTTP request and get the response.
            HttpWebResponse response     = this.SendMAPIHttpRequest(this.userName, this.password, requestBody, ServerEndpoint.AddressBookServerEndpoint, AdapterHelper.SessionContextCookies, webHeaderCollection, out rawBuffer);
            uint            responseCode = AdapterHelper.GetFinalResponseCode(response.Headers["X-ResponseCode"]);

            this.Site.Assert.AreEqual <uint>(0, responseCode, "The request to the address book server should be executed successfully!");

            // Read the HTTP response buffer and parse the response to correct format.
            commonResponse = CommonResponse.ParseCommonResponse(rawBuffer);
            Site.Assert.IsNotNull(commonResponse.ResponseBodyRawData, "The response body should contains data.");
            this.VerifyRequestTypesForAddressBookServerEndpoint(response.Headers, commonResponse);
            this.VerifyAutoDiscover(response.StatusCode, ServerEndpoint.AddressBookServerEndpoint);
            this.VerifyAuthentication(response);

            response.GetResponseStream().Close();
            if (cookieChange)
            {
                AdapterHelper.SessionContextCookies = response.Cookies;
            }

            return(commonResponse);
        }
All Usage Examples Of Microsoft.Protocols.TestSuites.MS_OXCMAPIHTTP.AdapterHelper::InitializeHTTPHeader