-
-
Notifications
You must be signed in to change notification settings - Fork 955
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed: Don't set cookies for static resources
Closes #4356
- Loading branch information
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/Sonarr.Http/Extensions/Pipelines/SetCookieHeaderPipeline.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Linq; | ||
using Nancy; | ||
using Nancy.Bootstrapper; | ||
|
||
namespace Sonarr.Http.Extensions.Pipelines | ||
{ | ||
public class SetCookieHeaderPipeline : IRegisterNancyPipeline | ||
{ | ||
public int Order => 99; | ||
|
||
public void Register(IPipelines pipelines) | ||
{ | ||
pipelines.AfterRequest.AddItemToEndOfPipeline((Action<NancyContext>) Handle); | ||
} | ||
|
||
private void Handle(NancyContext context) | ||
{ | ||
if (context.Request.IsContentRequest() || context.Request.IsBundledJsRequest()) | ||
{ | ||
var authCookie = context.Response.Cookies.FirstOrDefault(c => c.Name == "SonarrAuth"); | ||
|
||
if (authCookie != null) | ||
{ | ||
context.Response.Cookies.Remove(authCookie); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters