webmcp

annotate framework/env/auth/openid/_curl.lua @ 23:3a6fe8663b26

Code cleanup and documentation added; Year in copyright notice changed to 2009-2010

Details:
- Changed quoting style in auth.openid.xrds_document{...}
- Fixed documentation for auth.openid.initiate{...}
- Added documentation for mondelefant
- Code-cleanup in mondelefant:
-- removed unneccessary lines "rows = PQntuples(res); cols = PQnfields(res);"
-- avoided extra copy of first argument (self) in mondelefant_conn_query
-- no rawget in meta-method "__index" of database result lists and objects
-- removed unreachable "return 0;" in meta-method "__newindex" of database result lists and objects
- Year in copyright notice changed to 2009-2010
- Version string changed to "1.1.1"
author jbe
date Fri Jun 04 19:00:34 2010 +0200 (2010-06-04)
parents 47ddf0f86009
children 3d43a5cf17c1
rev   line source
jbe/bsw@20 1 function auth.openid._curl(url, curl_options)
jbe/bsw@20 2 -- NOTE: Don't accept URLs starting with file:// or other nasty protocols
jbe/bsw@20 3 if not string.find(url, "^[Hh][Tt][Tt][Pp][Ss]?://") then
jbe/bsw@20 4 return nil
jbe/bsw@20 5 end
jbe/bsw@20 6 local options = table.new(curl_options)
jbe/bsw@20 7 options[#options+1] = "-i"
jbe/bsw@20 8 options[#options+1] = url
jbe/bsw@20 9 local stdout, errmsg, status = os.pfilter(nil, "curl", unpack(options))
jbe/bsw@20 10 if not stdout then
jbe/bsw@20 11 error("Error while executing curl: " .. errmsg)
jbe/bsw@20 12 end
jbe/bsw@20 13 if status ~= 0 then
jbe/bsw@20 14 return nil
jbe/bsw@20 15 end
jbe/bsw@20 16 local status = tonumber(string.match(stdout, "^[^ ]+ *([0-9]*)"))
jbe/bsw@20 17 local headers = string.match(stdout, "(\r?\n.-\r?\n)\r?\n")
jbe/bsw@20 18 local body = string.match(stdout, "\r?\n\r?\n(.*)")
jbe/bsw@20 19 return status, headers, body
jbe/bsw@20 20 end

Impressum / About Us