add mono CreateWebRequest workaround

This commit is contained in:
Luke Pulverenti 2015-06-07 17:21:30 -04:00
parent c0125c03fd
commit e8322b4a12
4 changed files with 36 additions and 11 deletions

View File

@ -445,6 +445,8 @@ namespace MediaBrowser.Api.Playback.Hls
var segmentFilename = Path.GetFileName(segmentPath);
while (!cancellationToken.IsCancellationRequested)
{
try
{
using (var fileStream = GetPlaylistFileStream(playlistPath))
{
@ -462,6 +464,11 @@ namespace MediaBrowser.Api.Playback.Hls
}
}
}
}
catch (IOException)
{
// May get an error if the file is locked
}
await Task.Delay(100, cancellationToken).ConfigureAwait(false);
}

View File

@ -105,6 +105,23 @@ namespace MediaBrowser.Common.Implementations.HttpClientManager
return client;
}
private WebRequest CreateWebRequest(string url)
{
try
{
return WebRequest.Create(url);
}
catch (NotSupportedException)
{
//Webrequest creation does fail on MONO randomly when using WebRequest.Create
//the issue occurs in the GetCreator method here: http://www.oschina.net/code/explore/mono-2.8.1/mcs/class/System/System.Net/WebRequest.cs
var type = Type.GetType("System.Net.HttpRequestCreator, System, Version=4.0.0.0,Culture=neutral, PublicKeyToken=b77a5c561934e089");
var creator = Activator.CreateInstance(type, nonPublic: true) as IWebRequestCreate;
return creator.Create(new Uri(url)) as HttpWebRequest;
}
}
private WebRequest GetRequest(HttpRequestOptions options, string method, bool enableHttpCompression)
{
var request = WebRequest.Create(options.Url);

View File

@ -179,7 +179,8 @@ namespace MediaBrowser.Server.Implementations.ServerManager
if (!message.StartsWith("{", StringComparison.OrdinalIgnoreCase))
{
_logger.Error("Received web socket message that is not a json structure: " + message);
// This info is useful sometimes but also clogs up the log
//_logger.Error("Received web socket message that is not a json structure: " + message);
return;
}