home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
MediaPortal 1 Plugins
Popular Plugins
My TVSeries
MP-TVSeries v4.3.6 Release [2020-01-24]
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="ltfearme" data-source="post: 1263604" data-attributes="member: 52219"><p>Quick update, I added some code to handle redirects, but it looks like the secure updates url tries to redirect again but with no Location header.</p><p></p><p>[code]</p><p> string newUrl = null;</p><p> HttpWebRequest request = null;</p><p> HttpWebResponse response = null;</p><p> try</p><p> {</p><p> // .NET 4.0: Use TLS v1.2. Many download sources no longer support the older and now insecure TLS v1.0/1.1 and SSL v3.</p><p> ServicePointManager.SecurityProtocol = ( SecurityProtocolType )0xc00;</p><p> request = (HttpWebRequest)WebRequest.Create(sUrl);</p><p> // Note: some network proxies require the useragent string to be set or they will deny the http request</p><p> // this is true for instance for EVERY thailand internet connection (also needs to be set for banners/episodethumbs and any other http request we send)</p><p> request.UserAgent = Settings.UserAgent;</p><p> request.Timeout = 60000;</p><p> // turn off auto-redirection on the initial request.</p><p> // then we can pull out the header and do the redirection manually by making a new request.</p><p> request.AllowAutoRedirect = false;</p><p> response = (HttpWebResponse)request.GetResponse();</p><p> MPTVSeriesLog.Write( $"Status Code={ response.StatusCode }, Headers={ response.Headers }", MPTVSeriesLog.LogLevel.Debug );</p><p> // check for redirect</p><p> switch ( response.StatusCode )</p><p> {</p><p> case HttpStatusCode.Redirect:</p><p> case HttpStatusCode.MovedPermanently:</p><p> case HttpStatusCode.RedirectKeepVerb:</p><p> case HttpStatusCode.RedirectMethod:</p><p> newUrl = response.Headers["Location"];</p><p> if ( newUrl == null )</p><p> return null;</p><p> if ( newUrl.IndexOf( "://", System.StringComparison.Ordinal ) == -1 )</p><p> {</p><p> // doesn't have a URL Schema, meaning it's a relative or absolute URL</p><p> var u = new Uri( new Uri( sUrl ), newUrl );</p><p> newUrl = u.ToString();</p><p> }</p><p> // now re-request using new url</p><p> return RetrieveData( newUrl );</p><p> break;</p><p> }</p><p> </p><p> if (response != null) // Get the stream associated with the response.</p><p> return response.GetResponseStream();</p><p> }</p><p>[/code]</p><p></p><p>Does anyone know why that is? Known issue?</p><p></p><p>The request headers returns:</p><p>[code]</p><p>2019-11-21 16:41:30.371 [DEBG][05]: Retrieving Data from: https://thetvdb.com/api/<apikey>/updates/updates_month.zip</p><p>2019-11-21 16:41:30.475 [DEBG][05]: Status Code='Redirect', Headers=Connection: keep-alive</p><p>x-amzn-RequestId: d399016c-1663-442e-b65c-4e81e0529262</p><p>x-amz-apigw-id: DeqTcH6HvHcFRFw=</p><p>X-Amzn-Trace-Id: Root=1-5dd5bdaf-e52331d2b04543ae92f8ec6e;Sampled=0</p><p>X-Amz-Cf-Pop: SIN52-C2,SIN52-C2</p><p>X-Cache: Hit from cloudfront</p><p>X-Amz-Cf-Id: 3sj8ouyPvxLlCMmXo0lCMuP1LYUFc3ynpoNK78UVfvkA0jg5u3ptfg==</p><p>Age: 7817</p><p>Content-Length: 64</p><p>Content-Type: application/json</p><p>Date: Wed, 20 Nov 2019 22:26:55 GMT</p><p>Via: 1.1 21091692796ba0a5be0a5b521f44889c.cloudfront.net (CloudFront), 1.1 6b0d2463e38d8b2224f25b309fde2ba3.cloudfront.net (CloudFront)</p><p></p><p>[/code]</p></blockquote><p></p>
[QUOTE="ltfearme, post: 1263604, member: 52219"] Quick update, I added some code to handle redirects, but it looks like the secure updates url tries to redirect again but with no Location header. [code] string newUrl = null; HttpWebRequest request = null; HttpWebResponse response = null; try { // .NET 4.0: Use TLS v1.2. Many download sources no longer support the older and now insecure TLS v1.0/1.1 and SSL v3. ServicePointManager.SecurityProtocol = ( SecurityProtocolType )0xc00; request = (HttpWebRequest)WebRequest.Create(sUrl); // Note: some network proxies require the useragent string to be set or they will deny the http request // this is true for instance for EVERY thailand internet connection (also needs to be set for banners/episodethumbs and any other http request we send) request.UserAgent = Settings.UserAgent; request.Timeout = 60000; // turn off auto-redirection on the initial request. // then we can pull out the header and do the redirection manually by making a new request. request.AllowAutoRedirect = false; response = (HttpWebResponse)request.GetResponse(); MPTVSeriesLog.Write( $"Status Code={ response.StatusCode }, Headers={ response.Headers }", MPTVSeriesLog.LogLevel.Debug ); // check for redirect switch ( response.StatusCode ) { case HttpStatusCode.Redirect: case HttpStatusCode.MovedPermanently: case HttpStatusCode.RedirectKeepVerb: case HttpStatusCode.RedirectMethod: newUrl = response.Headers["Location"]; if ( newUrl == null ) return null; if ( newUrl.IndexOf( "://", System.StringComparison.Ordinal ) == -1 ) { // doesn't have a URL Schema, meaning it's a relative or absolute URL var u = new Uri( new Uri( sUrl ), newUrl ); newUrl = u.ToString(); } // now re-request using new url return RetrieveData( newUrl ); break; } if (response != null) // Get the stream associated with the response. return response.GetResponseStream(); } [/code] Does anyone know why that is? Known issue? The request headers returns: [code] 2019-11-21 16:41:30.371 [DEBG][05]: Retrieving Data from: https://thetvdb.com/api/<apikey>/updates/updates_month.zip 2019-11-21 16:41:30.475 [DEBG][05]: Status Code='Redirect', Headers=Connection: keep-alive x-amzn-RequestId: d399016c-1663-442e-b65c-4e81e0529262 x-amz-apigw-id: DeqTcH6HvHcFRFw= X-Amzn-Trace-Id: Root=1-5dd5bdaf-e52331d2b04543ae92f8ec6e;Sampled=0 X-Amz-Cf-Pop: SIN52-C2,SIN52-C2 X-Cache: Hit from cloudfront X-Amz-Cf-Id: 3sj8ouyPvxLlCMmXo0lCMuP1LYUFc3ynpoNK78UVfvkA0jg5u3ptfg== Age: 7817 Content-Length: 64 Content-Type: application/json Date: Wed, 20 Nov 2019 22:26:55 GMT Via: 1.1 21091692796ba0a5be0a5b521f44889c.cloudfront.net (CloudFront), 1.1 6b0d2463e38d8b2224f25b309fde2ba3.cloudfront.net (CloudFront) [/code] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
MediaPortal 1 Plugins
Popular Plugins
My TVSeries
MP-TVSeries v4.3.6 Release [2020-01-24]
Contact us
RSS
Top
Bottom