/// <summary> /// Initialize adapter. /// </summary> /// <param name="testSite">The test site instance associated with the current adapter.</param> public override void Initialize(ITestSite testSite) { base.Initialize(ReqConfigurableSite.GetReqConfigurableSite(testSite)); PccrtpBothRoleCapture.Initialize(testSite); this.pccrtpClientStack = new PccrtpClient(new Logger(testSite)); this.Site.DefaultProtocolDocShortName = "MS-PCCRTP"; SutOsVersion = (OSVersion)Enum.Parse( typeof(OSVersion), this.GetProperty("Environment.ContentServer.OSVersion"), true); }
/// <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); }
/// <summary> /// Initialize adapter. /// </summary> /// <param name="testSite">The test site instance associated with the current adapter.</param> public override void Initialize(ITestSite testSite) { base.Initialize(ReqConfigurableSite.GetReqConfigurableSite(testSite)); PccrtpBothRoleCapture.Initialize(testSite); this.Site.DefaultProtocolDocShortName = "MS-PCCRTP"; this.sutOsVersion = (OSVersion)Enum.Parse( typeof(OSVersion), this.Site.Properties["Environment.DistributedSUT.OSVersion"].ToString(), true); this.isIpv4 = bool.Parse(Site.Properties["PCCRTP.Protocol.Address.isIPv4"]); this.listenPort = int.Parse(Site.Properties["Environment.ContentServer.HTTP.Port"]); if (this.isIpv4) { this.pccrtpServerStack = new PccrtpServer(this.listenPort, IPAddressType.IPv4, new Logger(testSite)); } else { this.pccrtpServerStack = new PccrtpServer(this.listenPort, IPAddressType.IPv6, new Logger(testSite)); } this.pccrtpServerStack.StartServer(); }