Skip to content

Commit

Permalink
Add feature to suppress server header on send response
Browse files Browse the repository at this point in the history
  • Loading branch information
Scott Offen committed Aug 21, 2017
1 parent c07bdb8 commit 56b1e28
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Grapevine/Interfaces/Server/HttpResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,13 @@ public interface IHttpResponse

public class HttpResponse : IHttpResponse
{
private static string _server;
private static readonly string Server;
public static bool SuppressServerHeader { get; set; }

static HttpResponse()
{
var assembly = AppDomain.CurrentDomain.GetAssemblies().SingleOrDefault(a => a.GetName().Name == "Grapevine");
if (assembly != null) _server = $"{assembly.GetName().Name}/{assembly.GetName().Version}";
if (assembly != null) Server = $"{assembly.GetName().Name}/{assembly.GetName().Version}";
}

private ContentType _contentType;
Expand Down Expand Up @@ -290,7 +291,7 @@ public void SetCookie(Cookie cookie)

public void SendResponse(byte[] contents)
{
if (_server != null) Headers["Server"] = _server;
if (Server != null && !SuppressServerHeader) Headers["Server"] = Server;

if (RequestHeaders.AllKeys.Contains("Accept-Encoding") && RequestHeaders["Accept-Encoding"].Contains("gzip") && contents.Length > 1024)
{
Expand Down

0 comments on commit 56b1e28

Please sign in to comment.