jbe/bsw@20: function auth.openid._curl(url, curl_options) jbe/bsw@20: -- NOTE: Don't accept URLs starting with file:// or other nasty protocols jbe/bsw@20: if not string.find(url, "^[Hh][Tt][Tt][Pp][Ss]?://") then jbe/bsw@20: return nil jbe/bsw@20: end jbe/bsw@20: local options = table.new(curl_options) jbe/bsw@20: options[#options+1] = "-i" jbe/bsw@20: options[#options+1] = url jbe@65: local stdout, errmsg, status = extos.pfilter(nil, "curl", table.unpack(options)) jbe/bsw@20: if not stdout then jbe/bsw@20: error("Error while executing curl: " .. errmsg) jbe/bsw@20: end jbe/bsw@20: if status ~= 0 then jbe/bsw@20: return nil jbe/bsw@20: end jbe/bsw@20: local status = tonumber(string.match(stdout, "^[^ ]+ *([0-9]*)")) jbe/bsw@20: local headers = string.match(stdout, "(\r?\n.-\r?\n)\r?\n") jbe/bsw@20: local body = string.match(stdout, "\r?\n\r?\n(.*)") jbe/bsw@20: return status, headers, body jbe/bsw@20: end