Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

New Req:protocol() -> http | https

Includes support for inets and mochiweb, but not others
  • Loading branch information...
commit 72a31fb729ef70fc25684f920f103fc1ce0221d0 1 parent df56943
@evanmiller evanmiller authored
View
4 src/cowboy_bridge_modules/cowboy_request_bridge.erl
@@ -9,7 +9,7 @@
-export ([
init/1,
- request_method/1, path/1, uri/1,
+ protocol/1, request_method/1, path/1, uri/1,
peer_ip/1, peer_port/1,
headers/1, cookies/1,
query_params/1, post_params/1, request_body/1,
@@ -32,6 +32,8 @@ init({Req,DocRoot}) ->
?PUT,
ReqKey.
+protocol(_ReqKey) -> undefined.
+
request_method(ReqKey) ->
?GET,
{Method, Req} = cowboy_http_req:method(Req),
View
8 src/inets_bridge_modules/inets_request_bridge.erl
@@ -8,7 +8,7 @@
-include_lib ("simple_bridge.hrl").
-export ([
init/1,
- request_method/1, path/1, uri/1,
+ protocol/1, request_method/1, path/1, uri/1,
peer_ip/1, peer_port/1,
headers/1, cookies/1,
query_params/1, post_params/1, request_body/1,
@@ -19,6 +19,12 @@
init(Req) ->
Req.
+protocol(Req) ->
+ case Req#mod.socket of
+ S when is_tuple(S), element(1, S) =:= sslsocket -> https;
+ _ -> http
+ end.
+
request_method(Req) ->
list_to_atom(Req#mod.method).
View
4 src/misultin_bridge_modules/misultin_request_bridge.erl
@@ -3,7 +3,7 @@
-include_lib ("simple_bridge.hrl").
-export ([
init/1,
- request_method/1, path/1, uri/1,
+ protocol/1, request_method/1, path/1, uri/1,
peer_ip/1, peer_port/1,
headers/1, header/2, cookies/1,
query_params/1, post_params/1, request_body/1,
@@ -13,6 +13,8 @@
init(Req) ->
Req.
+protocol(_Req) -> undefined.
+
request_method(Req) ->
Req:get(method).
View
5 src/mochiweb_bridge_modules/mochiweb_request_bridge.erl
@@ -8,7 +8,7 @@
-include_lib ("simple_bridge.hrl").
-export ([
init/1,
- request_method/1, path/1, uri/1,
+ protocol/1, request_method/1, path/1, uri/1,
peer_ip/1, peer_port/1,
headers/1, header/2, cookies/1,
query_params/1, post_params/1, request_body/1,
@@ -25,6 +25,9 @@ init({Req, _DocRoot}) ->
init(Req) ->
Req.
+protocol(Req) ->
+ Req:get(scheme).
+
request_method(Req) ->
Req:get(method).
View
1  src/simple_bridge_request.erl
@@ -34,6 +34,7 @@ make_nocatch(Module, RequestData) ->
behaviour_info(callbacks) -> [
{init, 1}, % Should accept the request value passed by the http server.
+ {protocol, 1}, % http | https | undefined
{request_method, 1}, % GET, POST, etc.
{uri, 1}, % The uri (path and querystring)
{path, 1}, % Just the path. (http://server.com/<PATH>?querystring)
View
1  src/simple_bridge_request_wrapper.erl
@@ -12,6 +12,7 @@ set_multipart(PostParams1, PostFiles1) ->
set_error(Error1) ->
simple_bridge_request_wrapper:new(Mod, Req, true, PostParams, PostFiles, Error1).
+protocol() -> Mod:protocol(Req).
request_method() -> Mod:request_method(Req).
path() -> Mod:path(Req).
uri() -> Mod:uri(Req).
View
3  src/webmachine_bridge_modules/webmachine_request_bridge.erl
@@ -8,6 +8,7 @@
-export ([
init/1,
+ protocol/1,
request_method/1,
path/1,
uri/1,
@@ -25,6 +26,8 @@
init(Req) ->
Req.
+protocol(_Req) -> undefined.
+
request_method(Req) ->
wrq:method(Req).
View
4 src/yaws_bridge_modules/yaws_request_bridge.erl
@@ -6,7 +6,7 @@
-include_lib ("simple_bridge.hrl").
-export ([
init/1,
- request_method/1, path/1, uri/1,
+ request_method/1, protocol/1, path/1, uri/1,
peer_ip/1, peer_port/1,
headers/1, cookie/2, cookies/1,
query_params/1, post_params/1, request_body/1,
@@ -16,6 +16,8 @@
init(Req) ->
Req.
+protocol(_Arg) -> undefined.
+
request_method(Arg) ->
yaws_api:http_request_method(yaws_api:arg_req(Arg)).
Please sign in to comment.
Something went wrong with that request. Please try again.