User Tools

Site Tools



minionlib

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
minionlib [2020/12/14 08:18] – [HTTPRequest] frenkeyminionlib [2021/04/30 18:13] (current) ace
Line 88: Line 88:
     *Queues and Fires the Event with 1-n arguments. Eventname and arguments need to be strings.      *Queues and Fires the Event with 1-n arguments. Eventname and arguments need to be strings. 
     *Use RegisterEventHandler("eventname", handlerfunc) , to register a lua function which will handle the fired event.     *Use RegisterEventHandler("eventname", handlerfunc) , to register a lua function which will handle the fired event.
 +    *Requires at least 1 argument, even if it's a blank string. (ex. QueueEvent("some event",""))
  
  
Line 252: Line 253:
    local function success(str, header, statuscode)    local function success(str, header, statuscode)
       d("HTTP Request: success.")       d("HTTP Request: success.")
-      d("HTTP Result Header: " .. header)+      d("HTTP Result Header: " .. tostring(header))
       d("HTTP Result StatusCode: " .. tostring(statuscode))       d("HTTP Result StatusCode: " .. tostring(statuscode))
  
Line 260: Line 261:
          d(data)          d(data)
       end       end
 +      
 +      local function HeadersTable(header)
 +         if type(header) == "string" and #header > 0 then
 +            header = string.match(header,".?%c(.*)") -- Removing the first entry
 +            local tbl = {}
 +            for w in header:gmatch("[^%c]+") do
 +               local k,v = string.match(w,"(.*): (.*)")
 +               tbl[k] = v
 +            end
 +            table.print(tbl)
 +            return tbl
 +         end
 +      end
 +      
 +      header = HeadersTable(header) -- if you want to convert the header string to a table
    end    end
  
Line 272: Line 288:
       path = "/v2/currencies?ids=1",       path = "/v2/currencies?ids=1",
       port = 443,       port = 443,
-      method = "GET", -- GET or PUT+      method = "GET", -- "GET","POST","PUT","DELETE"
       https = true,       https = true,
       onsuccess = success,       onsuccess = success,
Line 278: Line 294:
       getheaders = true, --true will return the headers, if you dont need it you can leave this at nil       getheaders = true, --true will return the headers, if you dont need it you can leave this at nil
       body = "", --optional, if not required for your call can be nil or ""       body = "", --optional, if not required for your call can be nil or ""
-      headers = "", --optional, if not required for your call can be nil or ""+      headers = {}, --optional, if not required for your call can be nil or ""
    }    }
  
minionlib.1607933881.txt.gz · Last modified: 2020/12/14 08:18 by frenkey