http.lua 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. ---@meta
  2. ---`HTTPRequest` definition
  3. ---------------------------
  4. -- Used by `HTTPApiTable.fetch` and `HTTPApiTable.fetch_async`.
  5. ---@class mt.HTTPReqDef
  6. ---@field url string
  7. -- Timeout for request to be completed in seconds. Default depends on engine settings.
  8. ---@field timeout number
  9. -- The http method to use. Defaults to "GET".
  10. ---@field method "GET"|"POST"|"PUT"|"DELETE"
  11. -- Data for the POST, PUT or DELETE request.
  12. -- Accepts both a string and a table. If a table is specified, encodes
  13. -- table as x-www-form-urlencoded key-value pairs.
  14. ---@field data string|table
  15. -- Optional, if specified replaces the default minetest user agent with
  16. -- given string.
  17. ---@field user_agent string|nil
  18. -- Optional, if specified adds additional headers to the HTTP request.
  19. -- You must make sure that the header strings follow HTTP specification
  20. -- ("Key: Value").
  21. --
  22. -- Example: `{ "Accept-Language: en-us", "Accept-Charset: utf-8" }`.
  23. ---@field extra_headers table|nil
  24. -- * Optional, if true performs a multipart HTTP request.
  25. -- * Default is false.
  26. -- * Post only, data must be array.
  27. ---@field multipart boolean|nil
  28. -- Deprecated, use `data` instead. Forces `method = "POST"`.
  29. ---@field post_data string|table