http

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2023 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// default http User Agent
	DefaultUserAgent = `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/106.0.0.0 Safari/537.36`
	// default http timeout
	DefaultTimeout = 2 * time.Minute
)

Variables

This section is empty.

Functions

func DoRequest

func DoRequest(L *lua.LState) int

DoRequest lua http_client_ud:do_request() http_client_ud:do_request(http_request_ud) returns (response, error)

response: {
  code = http_code (200, 201, ..., 500, ...),
  body = string
  headers = table
}

func HeaderSet

func HeaderSet(L *lua.LState) int

request:header_set(key, value)

func Loader

func Loader(L *lua.LState) int

Loader is the module loader function.

func New

func New(L *lua.LState) int

http.client(config) returns (user data, error) config table:

{
  proxy="http(s)://<user>:<password>@host:<port>",
  timeout= 10,
  insecure_ssl=false,
  user_agent = "gopher-lua",
  basic_auth_user = "",
  basic_auth_password = "",
  headers = {"key"="value"},
  debug = false,
}

func NewFileRequest

func NewFileRequest(L *lua.LState) int

http.filerequest(url, files, params) returns user-data, error

func NewRequest

func NewRequest(L *lua.LState) int

http.request(verb, url, body) returns user-data, error

func Preload

func Preload(L *lua.LState)

Preload adds http_client to the given Lua state's package.preload table. After it has been preloaded, it can be loaded using require:

local http_client = require("http_client")

func SetBasicAuth

func SetBasicAuth(L *lua.LState) int

request:set_basic_auth(username, password)

Types

type LuaClient

type LuaClient struct {
	*http.Client
	// contains filtered or unexported fields
}

func (*LuaClient) DoRequest

func (client *LuaClient) DoRequest(req *http.Request) (*http.Response, error)

DoRequest() process request with needed settings for request

func (*LuaClient) PostFormRequest

func (client *LuaClient) PostFormRequest(url string, data url.Values) (*http.Response, error)

PostFormRequest() process Form

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL