Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header/2 function in mochiweb_request_bridge.erl #2

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/mochiweb_bridge_modules/mochiweb_request_bridge.erl
Expand Up @@ -9,7 +9,7 @@
init/1, init/1,
request_method/1, path/1, uri/1, request_method/1, path/1, uri/1,
peer_ip/1, peer_port/1, peer_ip/1, peer_port/1,
headers/1, cookies/1, headers/1, header/2, cookies/1,
query_params/1, post_params/1, request_body/1, query_params/1, post_params/1, request_body/1,
socket/1, recv_from_socket/3 socket/1, recv_from_socket/3
]). ]).
Expand Down Expand Up @@ -64,6 +64,14 @@ headers({Req, _DocRoot}) ->
], ],
[{K, V} || {K, V} <- Headers1, V /= undefined]. [{K, V} || {K, V} <- Headers1, V /= undefined].


header(Header,Req) when is_atom(Header) ->
F = fun($_) -> $-;(X) -> X end,
HeaderAsString = [F(X) || X <- erlang:atom_to_list(Header)],
header(HeaderAsString,Req);
header(Header,{Req, _DocRoot}) when is_list(Header) ->
Req:get_header_value(Header).


cookies({Req, _DocRoot}) -> cookies({Req, _DocRoot}) ->
Req:parse_cookie(). Req:parse_cookie().


Expand Down