Microsoft.Protocols.TestTools.StackSdk.BranchCache.Pccrtp.PccrtpClient.CreatePccrtpRequest C# (CSharp) Method

CreatePccrtpRequest() public method

Create PCCRTP request message.
public CreatePccrtpRequest ( string serverAddress, int port, string requestFileName, BranchCacheVersion version = BranchCacheVersion.V1, bool missingData = false ) : PccrtpRequest
serverAddress string The server address.
port int The port.
requestFileName string The request uri.
version BranchCacheVersion Version of branch cache.
missingData bool True if this is a missing data request; false otherwise.
return PccrtpRequest
        public PccrtpRequest CreatePccrtpRequest(
            string serverAddress,
            int port,
            string requestFileName,
            BranchCacheVersion version = BranchCacheVersion.V1,
            bool missingData = false)
        {
            this.pccrtpRequest.ServerAddress = serverAddress;
            this.pccrtpRequest.Port = port;
            this.pccrtpRequest.RequestFileName = requestFileName;

            Dictionary<string, string> tempHttpHeader = new Dictionary<string, string>();

            tempHttpHeader.Add(PccrtpConsts.AcceptEncodingHttpHeader, "peerdist");
            switch (version)
            {
                case BranchCacheVersion.V1:
                    tempHttpHeader.Add(PccrtpConsts.XP2PPeerDistHttpHeader, "Version=1.0" + (missingData ? ",MissingDataRequest=true" : ""));
                    break;
                case BranchCacheVersion.V2:
                    tempHttpHeader.Add(PccrtpConsts.XP2PPeerDistHttpHeader, "Version=1.1" + (missingData ? ",MissingDataRequest=true" : ""));
                    tempHttpHeader.Add(PccrtpConsts.XP2PPeerDistExHttpHeader, "MinContentInformation=1.0, MaxContentInformation=2.0");
                    break;
                default:
                    throw new NotImplementedException();
            }
            this.pccrtpRequest.HttpHeader = tempHttpHeader;
            return this.pccrtpRequest;
        }

Usage Example

        public void ContentServer_PccrtpServer_ContentEncodingNotHavePeerDist()
        {
            CheckApplicability();

            PccrtpClient pccrtpClient = new PccrtpClient();
            PccrtpRequest pccrtpRequest = pccrtpClient.CreatePccrtpRequest(
                testConfig.ContentServerComputerName,
                testConfig.ContentServerHTTPListenPort,
                testConfig.NameOfFileWithMultipleBlocks);

            BaseTestSite.Log.Add(
                LogEntryKind.Debug,
                "Send PCCRTP request to trigger hash generation");

            PccrtpResponse pccrtpResponse = pccrtpClient.SendHttpRequest(
                Microsoft.Protocols.TestTools.StackSdk.BranchCache.Pccrtp.HttpVersionType.HttpVersion11,
                pccrtpRequest,
                (int)testConfig.Timeout.TotalMilliseconds);

            var contentBeforeHashGeneration = pccrtpResponse.PayloadData;

            BaseTestSite.Log.Add(
                LogEntryKind.Debug,
                "Wait until the hash is generated on content server");

            TestUtility.DoUntilSucceed(() => sutControlAdapter.IsHTTPHashExisted(testConfig.ContentServerComputerFQDNOrNetBiosName), testConfig.Timeout, testConfig.RetryInterval);

            BaseTestSite.Log.Add(
                LogEntryKind.Debug,
                "Send HTTP request again without peerdist Accept-Encoding");

            var contentAfterHashGeneration = TestUtility.DownloadHTTPFile(testConfig.ContentServerComputerName, testConfig.NameOfFileWithMultipleBlocks);

            BaseTestSite.Assert.IsTrue(
               contentAfterHashGeneration.SequenceEqual(contentBeforeHashGeneration),
               "The content server should return file content when peerdist is not included in Accept-Encoding");
        }
All Usage Examples Of Microsoft.Protocols.TestTools.StackSdk.BranchCache.Pccrtp.PccrtpClient::CreatePccrtpRequest