Microsoft.Protocols.TestSuites.MS_OXCMAPIHTTP.MS_OXCMAPIHTTPAdapter.VerifyHTTPHeaders C# (CSharp) Method

VerifyHTTPHeaders() private method

Verify the requirements related to HTTP header.
private VerifyHTTPHeaders ( WebHeaderCollection headers ) : void
headers System.Net.WebHeaderCollection The collection of HTTP headers.
return void
        private void VerifyHTTPHeaders(WebHeaderCollection headers)
        {
            // If the response includes the Transfer-Encoding header, then the response is a chunked response.
            if (!string.IsNullOrEmpty(headers["Transfer-Encoding"]))
            {
                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R62");

                // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R62
                // If the response includes Transfer-Encoding header, then this response is a chunked response.
                // If Content-Length header is not included in response, then R62 is verified.
                this.Site.CaptureRequirementIfIsNull(
                    headers["Content-Length"],
                    62,
                    @"[In Content-Length Header Field] This header [Content-Length Header] is not used in chunked requests and chunked responses.");

                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R76");

                // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R76
                this.Site.CaptureRequirementIfAreEqual<string>(
                    "chunked",
                    headers["Transfer-Encoding"],
                    76,
                    @"[In Transfer-Encoding Header Field] The Transfer-Encoding header field contains the string ""chunked"" transfer coding, as specified in [RFC2616] section 3.6.");
            }

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R132: the X-ResponseCode header is {0}.", headers["X-ResponseCode"]);

            // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R132
            int responseCodeValue;

            this.Site.CaptureRequirementIfIsTrue(
                int.TryParse(headers["X-ResponseCode"], out responseCodeValue),
                132,
                @"[In X-ResponseCode Header Field] The X-ResponseCode header contains a numerical value that represents the specific result that occurred on the server.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R155: the X-ClientInfo header is {0}.", headers["X-ClientInfo"]);

            // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R155
            this.Site.CaptureRequirementIfIsFalse(
                string.IsNullOrEmpty(headers["X-ClientInfo"]),
                155,
                @"[In X-ClientInfo Header Field] The X-ClientInfo header field MUST be a combination of a globally unique value in the format of a GUID followed by a decimal counter (for example, ""{2EF33C39-49C8-421C-B876-CDF7F2AC3AA0}:123"").");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R164: the X-ServerApplication header is {0}.", headers["X-ServerApplication"]);

            // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R164
            this.Site.CaptureRequirementIfIsFalse(
                string.IsNullOrEmpty(headers["X-ServerApplication"]),
                164,
                @"[In X-ServerApplication Header Field] On every response, the server includes the X-ServerApplication header to indicate to the client what server version is being used.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R165: the X-ServerApplication header is {0}.", headers["X-ServerApplication"]);

            // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R165
            this.Site.CaptureRequirementIfIsTrue(
                Regex.IsMatch(headers["X-ServerApplication"], @"^Exchange/15.\d{2}.\d{4}.\d{3}$"),
                165,
                @"[In X-ServerApplication Header Field] The value of this header field [X-ServerApplication] has the following format: ""Exchange/15.xx.xxxx.xxx"".");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R167: the X-ExpirationInfo header is {0}.", headers["X-ExpirationInfo"]);

            // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R167
            this.Site.CaptureRequirementIfIsFalse(
                string.IsNullOrEmpty(headers["X-ExpirationInfo"]),
                167,
                @"[In X-ExpirationInfo Header Field] The X-ExpirationInfo header is returned by the server in every response to notify the client of the number of milliseconds before the server times-out the Session Context.");

            string setCookieHeader = headers["Set-Cookie"];

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R68: the Set-Cookie is {0}.", setCookieHeader);

            // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R68
            bool isVerifiedR68 = Regex.IsMatch(setCookieHeader, "^.*=.*$");

            this.Site.CaptureRequirementIfIsTrue(
                isVerifiedR68,
                68,
                @"[In Set-Cookie Header Field] The Set-Cookie header field contains an opaque value of the form <cookie name>=<opaque string>.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R1236");

            // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R1236
            this.Site.CaptureRequirementIfIsFalse(
                string.IsNullOrEmpty(headers["Set-Cookie"]),
                1236,
                @"[In Responding to All Request Type Requests] The response includes all Set-Cookie headers as specified in section 2.2.3.2.4 associated with the Session Context.");

            string pendingPeriodHeader = headers["X-PendingPeriod"];
            int pendingPeriod = 0;

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R157");

            // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R157
            this.Site.CaptureRequirementIfIsTrue(
                pendingPeriodHeader != null && int.TryParse(pendingPeriodHeader, out pendingPeriod),
                157,
                @"[In X-PendingPeriod Header Field] The X-PendingPeriod header field, returned by the server, specifies the number of milliseconds to be expected between keep-alive PENDING meta-tags in the response stream while the server is executing the request.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R158");

            // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R158
            this.Site.CaptureRequirementIfAreEqual<int>(
                15000,
                pendingPeriod,
                158,
                @"[In X-PendingPeriod Header Field] The default value of this header [X-PendingPeriod] is 15000 milliseconds (15 seconds).");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R1242");

            // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R1242
            this.Site.CaptureRequirementIfIsTrue(
                pendingPeriodHeader != null && int.TryParse(pendingPeriodHeader, out pendingPeriod),
                1242,
                @"[In Responding to All Request Type Requests] Since the keep-alive interval is configurable or auto-adjusted, the server MUST return the X-PendingPeriod header, specified in section 2.2.3.3.3, within the immediate response to tell the client the number of milliseconds to be expected between keep-alive responses from the server during the time a request is currently being executed on the server.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R1243");

            // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R1243
            this.Site.CaptureRequirementIfAreEqual<int>(
                15000,
                pendingPeriod,
                1243,
                @"[In Responding to All Request Type Requests] The default value of the X-PendingPeriod header is 15 seconds.");

            // Add the debug information
            this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXCMAPIHTTP_R2050");

            // Verify MS-OXCMAPIHTTP requirement: MS-OXCMAPIHTTP_R2050
            this.Site.CaptureRequirementIfIsTrue(
                string.IsNullOrEmpty(headers["X-DeviceInfo"]),
                2050,
                @"[In X-DeviceInfo Header Field] The server MUST not send this header [X-DeviceInfo] in a response to a client endpoint. ");
        }
MS_OXCMAPIHTTPAdapter