aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src/http_server/httpd_example.erl
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2016-04-26 12:01:03 +0200
committerErlang/OTP <[email protected]>2016-04-26 12:01:03 +0200
commit7c8866b6b4fabb0ef6e35384c30a60e7c5b73e91 (patch)
tree79dc21769a8c4b19c36fd1284ee891ea0482ff56 /lib/inets/src/http_server/httpd_example.erl
parentfbcbe079db40e63c1d9dc264139e3c4cc08c1cdd (diff)
parent235c32bcb1f91f803ba3d3c8a01edc1399d7a398 (diff)
downloadotp-7c8866b6b4fabb0ef6e35384c30a60e7c5b73e91.tar.gz
otp-7c8866b6b4fabb0ef6e35384c30a60e7c5b73e91.tar.bz2
otp-7c8866b6b4fabb0ef6e35384c30a60e7c5b73e91.zip
Merge branch 'ingela/inets/http_server-ssl-peer-cert/OTP-13510' into maint-18
* ingela/inets/http_server-ssl-peer-cert/OTP-13510: inets: Prepare for release inets: Add peer_cert to ESI environment
Diffstat (limited to 'lib/inets/src/http_server/httpd_example.erl')
-rw-r--r--lib/inets/src/http_server/httpd_example.erl18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/inets/src/http_server/httpd_example.erl b/lib/inets/src/http_server/httpd_example.erl
index 0222487a4b..ad29b5b29a 100644
--- a/lib/inets/src/http_server/httpd_example.erl
+++ b/lib/inets/src/http_server/httpd_example.erl
@@ -20,7 +20,7 @@
%%
-module(httpd_example).
-export([print/1]).
--export([get/2, post/2, yahoo/2, test1/2, get_bin/2]).
+-export([get/2, post/2, yahoo/2, test1/2, get_bin/2, peer/2]).
-export([newformat/3]).
%% These are used by the inets test-suite
@@ -94,10 +94,26 @@ default(Env,Input) ->
io_lib:format("~p",[httpd:parse_query(Input)]),"\n",
footer()].
+peer(Env, Input) ->
+ Header =
+ case proplists:get_value(peer_cert, Env) of
+ undefined ->
+ header("text/html", "Peer-Cert-Exist:false");
+ _ ->
+ header("text/html", "Peer-Cert-Exist:true")
+ end,
+ [Header,
+ top("Test peer_cert environment option"),
+ "<B>Peer cert:</B> ",
+ io_lib:format("~p",[proplists:get_value(peer_cert, Env)]),"\n",
+ footer()].
+
header() ->
header("text/html").
header(MimeType) ->
"Content-type: " ++ MimeType ++ "\r\n\r\n".
+header(MimeType, Other) ->
+ "Content-type: " ++ MimeType ++ "\r\n" ++ Other ++ "\r\n\r\n".
top(Title) ->
"<HTML>