VerifyPccrtpCommonHeader() public static method

Verify both role requirements about HTTP header.
public static VerifyPccrtpCommonHeader ( string>.Dictionary httpHeader ) : void
httpHeader string>.Dictionary Indicates the pair of key and value of the HTTP request or response header.
return void
Ejemplo n.º 1
0
        /// <summary>
        /// Receive a PCCRTP request message from the HTTP/1.1 client (SUT) when testing client endpoint.
        /// </summary>
        /// <returns>Return the PCCRTP request message received.</returns>
        public PccrtpRequest ReceivePccrtpRequestMessage()
        {
            TimeSpan timeOut = TimeSpan.FromSeconds(double.Parse(Site.Properties["PCCRTP.Protocol.TimeOut"]));

            this.pccrtpRequest = this.pccrtpServerStack.ReceivePccrtpRequest(timeOut);
            this.pccrtpRequest.DecodeHttpHeader(this.pccrtpRequest.HttpRequest);
            PccrtpBothRoleCapture.VerifyTransport(this.pccrtpRequest.HttpRequest.ProtocolVersion.ToString());
            PccrtpBothRoleCapture.VerifyPccrtpCommonHeader(this.pccrtpRequest.HttpHeader);
            this.VerifyPccrtpRequestRequirements();

            return(this.pccrtpRequest);
        }
        /// <summary>
        /// Send a PCCRTP request message and receive a PCCRTP response message.
        /// </summary>
        /// <param name="httpVersion">Indicates the HTTP version type used.</param>
        /// <param name="isRequestPartialContent">Indicates it is requesting partical content or not.</param>
        /// <param name="uri">Indicates the URI on the SUT requested by the client.</param>
        /// <returns>Return the PCCRTP response message received.</returns>
        public PccrtpResponse SendPccrtpRequestMessage(
            HttpVersionType httpVersion,
            bool isRequestPartialContent,
            string uri)
        {
            PccrtpRequest  pccrtpRequest  = new PccrtpRequest();
            PccrtpResponse pccrtpResponse = new PccrtpResponse();
            string         serverAddress  = this.GetProperty("Environment.ContentServer.MachineName");
            int            port           = int.Parse(this.GetProperty("Environment.ContentServer.HTTP.Port"));
            int            timeOut        = (int)TimeSpan.FromSeconds(
                double.Parse(this.GetProperty("PCCRTP.Protocol.TimeOut"))).TotalMilliseconds;
            int rangeFrom = int.Parse(this.GetProperty("PCCRTP.Protocol.RangeFrom"));
            int rangeTo   = int.Parse(this.GetProperty("PCCRTP.Protocol.RangeTo"));

            if (isRequestPartialContent)
            {
                pccrtpRequest  = this.pccrtpClientStack.CreatePccrtpRequest(serverAddress, port, uri);
                pccrtpResponse = this.pccrtpClientStack.SendHttpRequest(
                    httpVersion,
                    pccrtpRequest,
                    timeOut,
                    rangeFrom,
                    rangeTo);
            }
            else
            {
                pccrtpRequest  = this.pccrtpClientStack.CreatePccrtpRequest(serverAddress, port, uri);
                pccrtpResponse = this.pccrtpClientStack.SendHttpRequest(httpVersion, pccrtpRequest, timeOut);
            }

            if (pccrtpResponse.HttpResponse.ContentEncoding.Equals("peerdist"))
            {
                PccrtpBothRoleCapture.VerifyTransport(pccrtpResponse.HttpResponse.ProtocolVersion.ToString());
                PccrtpBothRoleCapture.VerifyPccrtpCommonHeader(pccrtpResponse.HttpHeader);
                this.VerifyPccrtpResponse(pccrtpResponse);
                this.VerifyContentInfomationStructure(pccrtpResponse);
            }

            return(pccrtpResponse);
        }