http set keepalive: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Function|Server|1.0.3}} {{FuncDescription|Sets if this request should have the keep alive flag. (Default: false)}} {{FuncSyntax|http_set_keepalive(http, keepalive)}}..." |
No edit summary |
||
Line 7: | Line 7: | ||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|http|The http identifier.}} | {{FuncParam|http|The http identifier.}} | ||
{{FuncParam| | {{FuncParam|keepalive|'''true''' to enable keep alive.}} | ||
{{FuncReturnValue|Returns '''true''' on success.}} | {{FuncReturnValue|Returns '''true''' on success.}} |
Latest revision as of 17:07, 24 January 2020
Description
Sets if this request should have the keep alive flag. (Default: false)
Syntax
http_set_keepalive(http, keepalive)
Parameters
- http
The http identifier. - keepalive
true to enable keep alive.
Return Value
- Returns true on success.
Example
function test_post()
local r = http_create()
http_set_resolver_protocol(r, "ipv4")
http_set_protocol(r, "http")
http_set_host(r, "ptsv2.com")
http_set_port(r, 80)
http_set_target(r, "/t/ozoab-1577627726/post")
http_set_verb(r, "post")
http_set_timeout(r, 30)
http_set_version(r, 11)
http_set_keepalive(r, true)
http_set_field(r, "user-agent", "Onset Server "..GetGameVersionString())
local body = ""
body = body.."foo1="..url_encode("bar?")
body = body.."foo2="..url_encode("?d,_:%bar2?")
http_set_body(r, body)
http_set_field(r, "content-length", string.len(body))
http_set_field(r, "content-type", "application/x-www-form-urlencoded; charset=utf-8")
if http_send(r, OnPostComplete, 1, 3.14, "OK s") == false then
print("HTTP REQ NOT SENT :(")
http_destroy(r)
end
end
function OnPostComplete(a, b, c)
print("OnPostComplete", a, b, c)
end
See also
- url_encode
- http_count
- http_get_all
- http_is_valid
- http_create
- http_destroy
- http_is_error
- http_result_error
- http_result_body
- http_result_header
- http_result_status
- http_set_protocol
- http_set_resolver_protocol
- http_set_host
- http_set_port
- http_set_target
- http_set_verb
- http_set_timeout
- http_set_verifymode
- http_set_version
- http_set_keepalive
- http_set_field
- http_set_body
- http_send