diff options
author | Steven Barth <steven@midlink.org> | 2009-02-24 17:54:48 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2009-02-24 17:54:48 +0000 |
commit | ff2bc9081bb24e42dec9ccd46cdb4c377333dc59 (patch) | |
tree | ea14c5b622e9d79f149e5d3e3f2490bf4f5331ce /libs/httpclient/luasrc | |
parent | cebe6f031bc475e8e21102c4b5e378e1fa7bcf54 (diff) |
nixio: Finetuning of TLS-support
httpclient: HTTPS support
axTLS: enable diagnostic mode
Diffstat (limited to 'libs/httpclient/luasrc')
-rw-r--r-- | libs/httpclient/luasrc/httpclient.lua | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/libs/httpclient/luasrc/httpclient.lua b/libs/httpclient/luasrc/httpclient.lua index 6681f82aa..542e6b6cd 100644 --- a/libs/httpclient/luasrc/httpclient.lua +++ b/libs/httpclient/luasrc/httpclient.lua @@ -110,11 +110,11 @@ function request_raw(uri, options) return nil, -1, "unable to parse URI" end - if pr ~= "http" then + if pr ~= "http" and pr ~= "https" then return nil, -2, "protocol not supported" end - port = #port > 0 and port or "80" + port = #port > 0 and port or (pr == "https" and "443" or "80") path = #path > 0 and path or "/" options.depth = options.depth or 10 @@ -135,6 +135,15 @@ function request_raw(uri, options) sock:setsockopt("socket", "sndtimeo", options.sndtimeo or 15) sock:setsockopt("socket", "rcvtimeo", options.rcvtimeo or 15) + if pr == "https" then + local tls = options.tls_context or nixio.tls() + sock = tls:create(sock) + local stat, code, error = sock:connect() + if not stat then + return stat, code, error + end + end + -- Pre assemble fixes if protocol == "HTTP/1.1" then headers.Host = headers.Host or host |