fixed plugin assembly downloads as well as debug/release detection with nuget assemblies

This commit is contained in:
LukePulverenti
2013-02-25 00:17:59 -05:00
parent b075e0a5b9
commit 364fbb9e0c
8 changed files with 90 additions and 12 deletions

View File

@@ -241,6 +241,10 @@ namespace MediaBrowser.Common.Net
{
return false;
}
if (contentType.StartsWith("application/", StringComparison.OrdinalIgnoreCase))
{
return false;
}
return true;
}
@@ -257,7 +261,10 @@ namespace MediaBrowser.Common.Net
if (!compress || string.IsNullOrEmpty(RequestContext.CompressionType))
{
Response.ContentType = contentType;
return await factoryFn().ConfigureAwait(false);
var stream = await factoryFn().ConfigureAwait(false);
return new StreamWriter(stream);
}
string content;

View File

@@ -173,7 +173,7 @@ namespace MediaBrowser.Common.Net
// Misc
if (ext.Equals(".dll", StringComparison.OrdinalIgnoreCase))
{
return "application/x-msdownload";
return "application/octet-stream";
}
// Web

View File

@@ -0,0 +1,48 @@
using ServiceStack.Service;
using System.IO;
using System.Threading.Tasks;
namespace MediaBrowser.Common.Net
{
/// <summary>
/// Class StreamWriter
/// </summary>
public class StreamWriter : IStreamWriter
{
/// <summary>
/// Gets or sets the source stream.
/// </summary>
/// <value>The source stream.</value>
public Stream SourceStream { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="StreamWriter" /> class.
/// </summary>
/// <param name="source">The source.</param>
public StreamWriter(Stream source)
{
SourceStream = source;
}
/// <summary>
/// Writes to.
/// </summary>
/// <param name="responseStream">The response stream.</param>
public void WriteTo(Stream responseStream)
{
var task = WriteToAsync(responseStream);
Task.WaitAll(task);
}
/// <summary>
/// Writes to async.
/// </summary>
/// <param name="responseStream">The response stream.</param>
/// <returns>Task.</returns>
private Task WriteToAsync(Stream responseStream)
{
return SourceStream.CopyToAsync(responseStream);
}
}
}