Class Protocols.HTTP.Query

Description

Open and execute an HTTP query.

Example

HTTP.Query o=HTTP.Query();

void ok() { write("ok...\n"); write("%O\n", o->headers); exit(0); }

void fail() { write("fail\n"); exit(0); }

int main() { o->set_callbacks(ok, fail); o->async_request("pike.lysator.liu.se", 80, "HEAD / HTTP/1.0"); return -1; }


Variable buf
Variable headerbuf

string Protocols.HTTP.Query.buf
string Protocols.HTTP.Query.headerbuf

Description

Input buffers.


Variable con

Stdio.File|SSL.File|Stdio.UDP Protocols.HTTP.Query.con

Description

Connection to HTTP(s) server.


Variable errno

int Protocols.HTTP.Query.errno

Description

Errno copied from the connection or simulated for async operations.

Note

In Pike 7.8 and earlier hardcoded Linux values were used in async operations, 110 instead of System.ETIMEDOUT and 113 instead of System.EHOSTUNREACH.


Variable request_ok
Variable request_fail
Variable extra_args

local function(:void)|zero Protocols.HTTP.Query.request_ok
local function(:void)|zero Protocols.HTTP.Query.request_fail
array Protocols.HTTP.Query.extra_args

Description

Callbacks and arguments set by set_callbacks().


Variable headers

mapping Protocols.HTTP.Query.headers

Description

Headers as a mapping. All header names are in lower case, for convinience.


Variable host
Variable real_host
Variable port

string Protocols.HTTP.Query.host
string Protocols.HTTP.Query.real_host
int Protocols.HTTP.Query.port

Description

Connected host and port.

Used to detect whether keep-alive can be used.


Variable hostname_cache

mapping(string:array(string)) Protocols.HTTP.Query.hostname_cache

Description

Set this to a global mapping if you want to use a cache, prior of calling *request().


Variable timeout
Variable maxtime

int Protocols.HTTP.Query.timeout
int Protocols.HTTP.Query.maxtime

Description

timeout is the time to wait in seconds on connection and/or data. If data is fetched asynchronously the watchdog will be reset every time data is received. Defaults to 120 seconds. maxtime is the time the entire operation is allowed to take, no matter if the connection and data fetching is successful. This is by default indefinitely.

Note

These values only have effect in asynchroneous calls


Variable ok

int Protocols.HTTP.Query.ok

Description

Tells if the connection is successfull.


Variable protocol

string Protocols.HTTP.Query.protocol

Description

Protocol string, ie "HTTP/1.0".


Variable status
Variable status_desc

int Protocols.HTTP.Query.status
string Protocols.HTTP.Query.status_desc

Description

Status number and description (eg 200 and "ok").