mono fixes for http requests
This commit is contained in:
parent
6247929a62
commit
d2332264b3
|
@ -101,10 +101,35 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PropertyInfo _httpBehaviorPropertyInfo;
|
private WebRequest GetMonoRequest(HttpRequestOptions options, string method, bool enableHttpCompression)
|
||||||
|
|
||||||
private HttpWebRequest GetRequest(HttpRequestOptions options, string method, bool enableHttpCompression)
|
|
||||||
{
|
{
|
||||||
|
var request = WebRequest.Create(options.Url);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(options.AcceptHeader))
|
||||||
|
{
|
||||||
|
request.Headers.Add("Accept", options.AcceptHeader);
|
||||||
|
}
|
||||||
|
|
||||||
|
request.CachePolicy = new RequestCachePolicy(RequestCacheLevel.Revalidate);
|
||||||
|
request.ConnectionGroupName = GetHostFromUrl(options.Url);
|
||||||
|
request.Method = method;
|
||||||
|
request.Timeout = 20000;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(options.UserAgent))
|
||||||
|
{
|
||||||
|
request.Headers.Add("User-Agent", options.UserAgent);
|
||||||
|
}
|
||||||
|
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PropertyInfo _httpBehaviorPropertyInfo;
|
||||||
|
private WebRequest GetRequest(HttpRequestOptions options, string method, bool enableHttpCompression)
|
||||||
|
{
|
||||||
|
#if __MonoCS__
|
||||||
|
return GetMonoRequest(options, method, enableHttpCompression);
|
||||||
|
#endif
|
||||||
|
|
||||||
var request = HttpWebRequest.CreateHttp(options.Url);
|
var request = HttpWebRequest.CreateHttp(options.Url);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(options.AcceptHeader))
|
if (!string.IsNullOrEmpty(options.AcceptHeader))
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<Files>
|
<Files>
|
||||||
<File FileName="MediaBrowser.Server.Mono\Program.cs" Line="1" Column="1" />
|
<File FileName="MediaBrowser.Server.Mono\Program.cs" Line="1" Column="1" />
|
||||||
<File FileName="MediaBrowser.Server.Mono\IO\FileSystemFactory.cs" Line="1" Column="1" />
|
<File FileName="MediaBrowser.Server.Mono\IO\FileSystemFactory.cs" Line="1" Column="1" />
|
||||||
<File FileName="MediaBrowser.Server.Implementations\Persistence\SqliteExtensions.cs" Line="2" Column="14" />
|
<File FileName="MediaBrowser.Server.Implementations\Persistence\SqliteExtensions.cs" Line="22" Column="29" />
|
||||||
<File FileName="MediaBrowser.Server.Mono\Native\ServerAuthorization.cs" Line="1" Column="1" />
|
<File FileName="MediaBrowser.Server.Mono\Native\ServerAuthorization.cs" Line="1" Column="1" />
|
||||||
<File FileName="MediaBrowser.Server.Mono\Native\NativeApp.cs" Line="1" Column="1" />
|
<File FileName="MediaBrowser.Server.Mono\Native\NativeApp.cs" Line="1" Column="1" />
|
||||||
<File FileName="MediaBrowser.Server.Mono\Native\Assemblies.cs" Line="1" Column="1" />
|
<File FileName="MediaBrowser.Server.Mono\Native\Assemblies.cs" Line="1" Column="1" />
|
||||||
|
|
|
@ -90,11 +90,7 @@ namespace MediaBrowser.ServerApplication.FFMpeg
|
||||||
{
|
{
|
||||||
Url = url,
|
Url = url,
|
||||||
CancellationToken = CancellationToken.None,
|
CancellationToken = CancellationToken.None,
|
||||||
Progress = new Progress<double>(),
|
Progress = new Progress<double>()
|
||||||
|
|
||||||
// Make it look like a browser
|
|
||||||
// Try to hide that we're direct linking
|
|
||||||
UserAgent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.47 Safari/537.36"
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user