Exemplo n.º 1
0
        internal MSearchResponse(IHttpResponse response)
        {
            try
            {
                ResponseCastMethod = Convert.GetCastMetod(response);
                HostIp             = response.RemoteAddress;
                HostPort           = response.RemotePort;
                StatusCode         = response.StatusCode;
                ResponseReason     = response.ResponseReason;
                CacheControl       = TimeSpan.FromSeconds(Convert.GetMaxAge(response.Headers));
                Location           = Convert.UrlToUri(Convert.GetHeaderValue(response.Headers, "LOCATION"));
                Date           = Convert.ToRfc2616Date(Convert.GetHeaderValue(response.Headers, "DATE"));
                Ext            = response.Headers.ContainsKey("EXT");
                Server         = Convert.ConvertToServer(Convert.GetHeaderValue(response.Headers, "SERVER"));
                ST             = Convert.GetHeaderValue(response.Headers, "ST");
                USN            = Convert.GetHeaderValue(response.Headers, "USN");
                BOOTID         = Convert.GetHeaderValue(response.Headers, "BOOTID.UPNP.ORG");
                CONFIGID       = Convert.GetHeaderValue(response.Headers, "CONFIGID.UPNP.ORG");
                SEARCHPORT     = Convert.GetHeaderValue(response.Headers, "SEARCHPORT.UPNP.ORG");
                SECURELOCATION = Convert.GetHeaderValue(response.Headers, "SECURELOCATION.UPNP.ORG");

                Headers = HeaderHelper.SingleOutAdditionalHeaders(new List <string>
                {
                    "HOST", "CACHE-CONTROL", "LOCATION", "DATE", "EXT", "SERVER", "ST", "USN",
                    "BOOTID.UPNP.ORG", "CONFIGID.UPNP.ORG", "SEARCHPORT.UPNP.ORG", "SECURELOCATION.UPNP.ORG"
                }, response.Headers);
            }
            catch (Exception)
            {
                InvalidRequest = true;
            }
        }
Exemplo n.º 2
0
        public MSearchRequest(IHttpRequest request, ILogger logger = null)
        {
            try
            {
                LocalIpEndPoint  = request.LocalIpEndPoint;
                RemoteIpEndPoint = request.RemoteIpEndPoint;
                TransportType    = Convert.GetCastMetod(request);
                MAN       = Convert.GetHeaderValue(request.Headers, "MAN");
                MX        = TimeSpan.FromSeconds(Convert.ConvertStringToInt(Convert.GetHeaderValue(request.Headers, "MX")));
                ST        = new ST(Convert.GetHeaderValue(request.Headers, "ST"), ignoreError: true);
                UserAgent = Convert.ConvertToUserAgent(Convert.GetHeaderValue(request.Headers, "USER-AGENT"));
                HOST      = Convert.GetHeaderValue(request.Headers, "HOST");

                CPFN           = Convert.GetHeaderValue(request.Headers, "CPFN.UPNP.ORG");
                CPUUID         = Convert.GetHeaderValue(request.Headers, "CPUUID.UPNP.ORG");
                TCPPORT        = Convert.GetHeaderValue(request.Headers, "TCPPORT.UPNP.ORG");
                SECURELOCATION = Convert.GetHeaderValue(request.Headers, "SECURELOCATION.UPNP.ORG");

                Headers = HeaderHelper.SingleOutAdditionalHeaders(new List <string>
                {
                    "HOST", "CACHE-CONTROL", "MAN", "MX", "ST", "USER-AGENT",
                    "CPFN.UPNP.ORG", "CPUUID.UPNP.ORG", "TCPPORT.UPNP.ORG", "SECURELOCATION.UPNP.ORG"
                }, request.Headers);

                HasParsingError = request.HasParsingErrors;
            }
            catch (Exception ex)
            {
                logger?.Error(ex);
                InvalidRequest = true;
            }
        }
Exemplo n.º 3
0
        public MSearchRequest(IHttpRequest request)
        {
            try
            {
                SearchCastMethod = Convert.GetCastMetod(request);
                MAN            = Convert.GetHeaderValue(request.Headers, "MAN");
                HostIp         = request.RemoteAddress;
                HostPort       = request.RemotePort;
                MX             = TimeSpan.FromSeconds(Convert.ConvertStringToInt(Convert.GetHeaderValue(request.Headers, "MX")));
                ST             = Convert.GetHeaderValue(request.Headers, "ST");
                UserAgent      = Convert.ConvertToUserAgent(Convert.GetHeaderValue(request.Headers, "USER-AGENT"));
                CPFN           = Convert.GetHeaderValue(request.Headers, "CPFN.UPNP.ORG");
                CPUUID         = Convert.GetHeaderValue(request.Headers, "CPUUID.UPNP.ORG");
                TCPPORT        = Convert.GetHeaderValue(request.Headers, "TCPPORT.UPNP.ORG");
                SECURELOCATION = Convert.GetHeaderValue(request.Headers, "SECURELOCATION.UPNP.ORG");

                Headers = HeaderHelper.SingleOutAdditionalHeaders(new List <string>
                {
                    "HOST", "CACHE-CONTROL", "MAN", "MX", "ST", "USER-AGENT",
                    "CPFN.UPNP.ORG", "CPUUID.UPNP.ORG", "TCPPORT.UPNP.ORG", "SECURELOCATION.UPNP.ORG"
                }, request.Headers);
            }
            catch (Exception)
            {
                InvalidRequest = true;
            }
        }
Exemplo n.º 4
0
        internal MSearchResponse(IHttpResponse response, ILogger logger = null)
        {
            try
            {
                LocalIpEndPoint  = response.LocalIpEndPoint;
                RemoteIpEndPoint = response.RemoteIpEndPoint;
                HasParsingError  = response.HasParsingErrors;
                TransportType    = Convert.GetCastMetod(response);
                StatusCode       = response.StatusCode;
                ResponseReason   = response.ResponseReason;
                CacheControl     = TimeSpan.FromSeconds(Convert.GetMaxAge(response.Headers));
                Location         = Convert.UrlToUri(Convert.GetHeaderValue(response.Headers, "LOCATION"));
                Date             = Convert.ToRfc2616Date(Convert.GetHeaderValue(response.Headers, "DATE"));
                Ext            = response.Headers.ContainsKey("EXT");
                Server         = Convert.ConvertToServer(Convert.GetHeaderValue(response.Headers, "SERVER"));
                ST             = new ST(Convert.GetHeaderValue(response.Headers, "ST"), ignoreError: true);
                USN            = new USN(Convert.GetHeaderValue(response.Headers, "USN")); Convert.GetHeaderValue(response.Headers, "USN");
                BOOTID         = int.TryParse(Convert.GetHeaderValue(response.Headers, "BOOTID.UPNP.ORG"), out var b) ? b : 0;
                CONFIGID       = int.TryParse(Convert.GetHeaderValue(response.Headers, "CONFIGID.UPNP.ORG"), out var c) ? c : 0;
                SEARCHPORT     = int.TryParse(Convert.GetHeaderValue(response.Headers, "SEARCHPORT.UPNP.ORG"), out var s) ? s : 0;
                SECURELOCATION = Convert.GetHeaderValue(response.Headers, "SECURELOCATION.UPNP.ORG");

                Headers = HeaderHelper.SingleOutAdditionalHeaders(new List <string>
                {
                    "HOST", "CACHE-CONTROL", "LOCATION", "DATE", "EXT", "SERVER", "ST", "USN",
                    "BOOTID.UPNP.ORG", "CONFIGID.UPNP.ORG", "SEARCHPORT.UPNP.ORG", "SECURELOCATION.UPNP.ORG"
                }, response.Headers);

                RemoteIpEndPoint = response.RemoteIpEndPoint;
            }
            catch (Exception ex)
            {
                logger?.Error(ex);
                InvalidRequest = true;
            }
        }