-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
38 additions
and
1 deletion.
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
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,27 @@ | ||
%% | ||
%% @doc Modify default Accept: header coming from MSIE. | ||
%% | ||
%% Should be fixing https://github.com/extend/cowboy/issues/441 | ||
%% | ||
%% NB: Apply after cowboy_router and cowboy_ua middlewares. | ||
%% | ||
|
||
-module(cowboy_msie_fix_accept). | ||
-author('Vladimir Dronnikov <dronnikov@gmail.com>'). | ||
|
||
-behaviour(cowboy_middleware). | ||
-export([execute/2]). | ||
|
||
execute(Req, Env) -> | ||
{handler_opts, HandlerOpts} = lists:keyfind(handler_opts, 1, Env), | ||
case lists:keyfind(useragent, 1, HandlerOpts) of | ||
{useragent, {ie, windows}} -> | ||
{Headers, Req2} = cowboy_req:headers(Req), | ||
Req3 = cowboy_req:set([{headers, [ | ||
{<<"accept">>, | ||
<<"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8">>} | ||
| Headers]}], Req2), | ||
{ok, Req3, Env}; | ||
_Else -> | ||
{ok, Req, Env} | ||
end. |
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