Httpc: module # /appl/lib/httpc.b
{
PATH : con "/dis/lib/httpc.dis";
debug : int;
Request: adt {
host : string;
method : string;
uri : string;
http_version : string;
user_agent : string;
headers : list of string;
body : array of byte;
header_bytes : fn (r: self ref Request) : array of byte;
};
Response: adt {
status : list of string;
content_type : string;
headers : string;
body : list of array of byte;
last_modified : string; # can't be bothered to write a strftime parser
content_length : int;
body_string: fn(r : self ref Response) : string;
to_string : fn(r : self ref Response) : string;
};
Connection : adt {
c : ref Sys->Connection;
ssl_connection: ref SSL3->Context;
ssl_vers: int;
send_request: fn(c: self ref Connection, r : ref Request) : ref Response;
read_response: fn(c: self ref Connection) : ref Response;
gets: fn(c: self ref Connection, delim : byte) : string;
write: fn(c: self ref Connection, b: array of byte) : int;
read: fn(c: self ref Connection, n: int) : array of byte;
read_chunked: fn(c: self ref Connection) : list of array of byte;
read_unchunked: fn(c: self ref Connection, block_size:int) : list of array of byte;
};
init: fn();
new_connection:fn(dialstring : string) : ref Connection;
new_ssl_connection:fn(dialstring : string) : ref Connection;
urlencode : fn(unencoded : string) : string;
};
|