include ("import") func doRequest(_data) need_httplib() fvar(http_verb) switch(Method) case 0: http_verb = 'GET' case 1: http_verb = 'POST' case 2: if (isdef(Verb)) error("Custom request needs Verb set.") return end http_verb = Verb end if (linked(Connection)) conn_ = Connection else if (Protocol == 0) println(conn_, ' = httplib.HTTPConnection(', Host, ', ', Port, ')') else println(conn_, ' = httplib.HTTPSConnection(', Host, ', ', Port, (isndef(Key)?(', ' && Key):''), (isndef(Cert)?(', ' && Cert):''), ')') end println(conn_, '.connect()') end println('') println(conn_ && '.request("' && http_verb && '", ' && URL && ', body = ' && Body && (isset(Headers)?(', headers = ' && Headers):'') && ')') println(response && ' = ' && conn_ && '.getresponse()') event (onResult, response && '.status') end func Conn() return(conn_) end func Data() return(response && '.read()') end func RespHeaders() return(response && '.getheaders()') end