File browser.lua
The browser object is the plugins interface to the web. The object has the following methods:
get_uri(uri,exhed) : returns string,err and takes the uri in "http://" form,exhed are extra header lines you want to add , for example {"Range: bytes 0-100","User-agent: fake" }
get_head(uri,exhed,fallback) : returns string,err and takes the uri in "http://" form,exhed are extra header lines you want to add. returns only the header, not the the body. If fallback is true then a GET with range: bytes 0 is tryed
get_head_and_body(uri,exhed,fallback) : returns string,string,err and takes the same arguments of get_uri, but returns as the first value the header
pipe_uri(uri,callback,exhed) : Gets the uri and uses callback on the data received,exhed are extra header lines you want to add.
The callback takes a string (the data) argument and returns a couple. The first argument is the amount of byte served, if ~= from the sring.len of the argument it is considered an error, and an error message.
pipe_uri returns a string that is nil on error, "" on end of transmission. It also return an error if one.
See libero.lua for an example on how to use the callback.
pipe_uri_with_header(self,url,cb_h,cb_b,exhed) : As pipe uri, but uses cb_h for the header and cb_b fpor the body.
Since the browser module doesn't know the result of the GET it will not follow redirects. The mimer module uses this.
process_header(self,url,h) : Force the browser to process the header string h as though the browser went to url and received te header.
Updates referer and cookies from header h and returns 1,newurl if 3xx code. For use with pipe_uri_with_header.
post_uri(uri,post,exhed) : returns string,err and takes the uri in "http://" form, the post data in "name=val&..." form (you may need to urlescape it by hand), exhed
show() : Debug printing on the browser content.
whathaveweread() : returns the page's url we have returned (may differ from the requested if we got a redirect).
wherearewe() : returns the host we have contacted (may differ from the requested if we got a redirect).
add_cookie(url,c) :adds cookie c as if received browsing url
get_cookie(name) :returns the table containing all cookie attributes. Since the returned table is the same table the browser uses (ie, passed by references) be careful. If you modify its values the browser eill be affected too. url
verbose_mode() : activates the verbose logging of CURL
ssl_init_stuff() : some stuff for SSL
setIgnoreContentLength() : ignore content len HTTP header
Functions
| new (override_useragent) | Creates a new object. |
| ssl_enabled () | Returns true if the browser is SSL enabled. |