copy dashboard to the output folder and load from the file system, instead of using embedded resources

This commit is contained in:
Luke Pulverenti
2013-03-23 00:04:36 -04:00
parent 4bc27f3a65
commit b20151fff3
156 changed files with 806 additions and 9073 deletions

View File

@@ -1,5 +1,4 @@
using System.Net;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.IO;
using MediaBrowser.Common.Net;
using MediaBrowser.Model.Logging;
@@ -11,7 +10,7 @@ using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using MimeTypes = MediaBrowser.Common.Net.MimeTypes;
@@ -27,7 +26,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// </summary>
/// <value>The logger.</value>
public ILogger Logger { get; set; }
/// <summary>
/// Gets a value indicating whether this instance is range request.
/// </summary>
@@ -36,7 +35,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
{
get
{
return Request.Headers.AllKeys.Contains("Range");
return !string.IsNullOrEmpty(RequestContext.GetHeader("Range"));
}
}
@@ -55,8 +54,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
throw new ArgumentNullException("result");
}
Response.AddHeader("Vary", "Accept-Encoding");
return RequestContext.ToOptimizedResult(result);
}
@@ -200,11 +197,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
var compress = ShouldCompressResponse(contentType);
if (compress)
{
Response.AddHeader("Vary", "Accept-Encoding");
}
return ToStaticResult(contentType, factoryFn, compress, headersOnly).Result;
}
@@ -266,9 +258,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer
if (IsRangeRequest)
{
return new RangeRequestWriter(Request.Headers, httpListenerResponse, stream, headersOnly);
return new RangeRequestWriter(RequestContext.GetHeader("Range"), httpListenerResponse, stream, headersOnly);
}
httpListenerResponse.ContentLength64 = stream.Length;
return headersOnly ? null : new StreamWriter(stream, Logger);
}
@@ -332,22 +324,26 @@ namespace MediaBrowser.Server.Implementations.HttpServer
{
var isNotModified = true;
if (Request.Headers.AllKeys.Contains("If-Modified-Since"))
var ifModifiedSinceHeader = RequestContext.GetHeader("If-Modified-Since");
if (!string.IsNullOrEmpty(ifModifiedSinceHeader))
{
DateTime ifModifiedSince;
if (DateTime.TryParse(Request.Headers["If-Modified-Since"], out ifModifiedSince))
if (DateTime.TryParse(ifModifiedSinceHeader, out ifModifiedSince))
{
isNotModified = IsNotModified(ifModifiedSince.ToUniversalTime(), cacheDuration, lastDateModified);
}
}
var ifNoneMatchHeader = RequestContext.GetHeader("If-None-Match");
// Validate If-None-Match
if (isNotModified && (cacheKey.HasValue || !string.IsNullOrEmpty(Request.Headers["If-None-Match"])))
if (isNotModified && (cacheKey.HasValue || !string.IsNullOrEmpty(ifNoneMatchHeader)))
{
Guid ifNoneMatch;
if (Guid.TryParse(Request.Headers["If-None-Match"] ?? string.Empty, out ifNoneMatch))
if (Guid.TryParse(ifNoneMatchHeader ?? string.Empty, out ifNoneMatch))
{
if (cacheKey.HasValue && cacheKey.Value == ifNoneMatch)
{

View File

@@ -162,9 +162,18 @@ namespace MediaBrowser.Server.Implementations.HttpServer
if (!string.IsNullOrEmpty(exception.Message))
{
res.AddHeader("X-Application-Error-Code", exception.Message);
res.AddHeader("X-Application-Error-Code", exception.Message.Replace(Environment.NewLine, " "));
}
}
if (dto is CompressedResult)
{
// Per Google PageSpeed
// This instructs the proxies to cache two versions of the resource: one compressed, and one uncompressed.
// The correct version of the resource is delivered based on the client request header.
// This is a good choice for applications that are singly homed and depend on public proxies for user locality.
res.AddHeader("Vary", "Accept-Encoding");
}
});
}

View File

@@ -1,7 +1,6 @@
using ServiceStack.Service;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Net;
@@ -17,19 +16,19 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// <value>The source stream.</value>
private Stream SourceStream { get; set; }
private HttpListenerResponse Response { get; set; }
private NameValueCollection RequestHeaders { get; set; }
private string RangeHeader { get; set; }
private bool IsHeadRequest { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="StreamWriter" /> class.
/// </summary>
/// <param name="requestHeaders">The request headers.</param>
/// <param name="rangeHeader">The range header.</param>
/// <param name="response">The response.</param>
/// <param name="source">The source.</param>
/// <param name="isHeadRequest">if set to <c>true</c> [is head request].</param>
public RangeRequestWriter(NameValueCollection requestHeaders, HttpListenerResponse response, Stream source, bool isHeadRequest)
public RangeRequestWriter(string rangeHeader, HttpListenerResponse response, Stream source, bool isHeadRequest)
{
RequestHeaders = requestHeaders;
RangeHeader = rangeHeader;
Response = response;
SourceStream = source;
IsHeadRequest = isHeadRequest;
@@ -52,7 +51,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
_requestedRanges = new List<KeyValuePair<long, long?>>();
// Example: bytes=0-,32-63
var ranges = RequestHeaders["Range"].Split('=')[1].Split(',');
var ranges = RangeHeader.Split('=')[1].Split(',');
foreach (var range in ranges)
{