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
Last revisionBoth sides next revision
minionlib [2020/12/14 08:15] – [HTTPRequest] frenkeyminionlib [2021/01/17 20:19] – Response headers string to table example kali
Line 252: Line 252:
    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 260:
          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 287:
       path = "/v2/currencies?ids=1",       path = "/v2/currencies?ids=1",
       port = 443,       port = 443,
-      method = "GET",+      method = "GET", -- "GET","POST","PUT","DELETE"
       https = true,       https = true,
       onsuccess = success,       onsuccess = success,
Line 278: Line 293:
       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.txt · Last modified: 2021/04/30 18:13 by ace