Skip to content

Commit

Permalink
Fixing an issue where embedded files were read from the wrong assembly
Browse files Browse the repository at this point in the history
  • Loading branch information
ayende committed Oct 28, 2010
1 parent ffc6fe9 commit dfa78b4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
5 changes: 3 additions & 2 deletions Raven.Http/Extensions/HttpExtensions.cs
@@ -1,6 +1,7 @@
using System;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Text;
using System.Text.RegularExpressions;
using Newtonsoft.Json;
Expand Down Expand Up @@ -308,7 +309,7 @@ public static bool MatchEtag(this IHttpContext context, Guid etag)
return context.Request.Headers["If-None-Match"] == etag.ToString();
}

public static void WriteEmbeddedFile(this IHttpContext context, string ravenPath, string docPath)
public static void WriteEmbeddedFile(this IHttpContext context, Assembly asm, string ravenPath, string docPath)
{
var filePath = Path.Combine(ravenPath, docPath);
byte[] bytes;
Expand All @@ -322,7 +323,7 @@ public static void WriteEmbeddedFile(this IHttpContext context, string ravenPath
return;
}
string resourceName = "Raven.Database.Server.WebUI." + docPath.Replace("/", ".");
using (var resource = typeof(HttpExtensions).Assembly.GetManifestResourceStream(resourceName))
using (var resource = asm.GetManifestResourceStream(resourceName))
{
if (resource == null)
{
Expand Down
30 changes: 15 additions & 15 deletions Raven.Http/Responders/Favicon.cs
Expand Up @@ -3,22 +3,22 @@

namespace Raven.Http.Responders
{
public class Favicon : AbstractRequestResponder
{
public override string UrlPattern
{
get { return "^/favicon.ico$"; }
}
public class Favicon : AbstractRequestResponder
{
public override string UrlPattern
{
get { return "^/favicon.ico$"; }
}

public override string[] SupportedVerbs
{
get { return new[] {"GET"}; }
}
public override string[] SupportedVerbs
{
get { return new[] { "GET" }; }
}

public override void Respond(IHttpContext context)
{
context.WriteEmbeddedFile(Settings.WebDir,"favicon.ico");
}
public override void Respond(IHttpContext context)
{
context.WriteEmbeddedFile(ResourceStore.GetType().Assembly, Settings.WebDir, "favicon.ico");
}

public override bool IsUserInterfaceRequest
{
Expand All @@ -27,5 +27,5 @@ public override bool IsUserInterfaceRequest
return true;
}
}
}
}
}
2 changes: 1 addition & 1 deletion Raven.Http/Responders/RavenUI.cs
Expand Up @@ -26,7 +26,7 @@ public override string[] SupportedVerbs
public override void Respond(IHttpContext context)
{
var docPath = context.GetRequestUrl().Replace("/raven/", "");
context.WriteEmbeddedFile(Settings.WebDir, docPath);
context.WriteEmbeddedFile(ResourceStore.GetType().Assembly,Settings.WebDir, docPath);
}


Expand Down

0 comments on commit dfa78b4

Please sign in to comment.