A way faster http access library that uses C extension based on mhttp
to do the calls.
initialise the mhttp library - must be called once to reset all internals,
use http_reset() if you dont need to reset your headers before the next call.
http_set_protocol(1); # now operating in HTTP 1.1 mode
Set the protocol level to use - either HTTP 1.0 or 1.1 by passing 0 or 1 -
the default is 0 (HTTP 1.0).
reset the library internals for everything except the headers specified
previously, and the debug switch. Call http_init() if you need to reset
switch_debug(<0 || 1>)
Toggle the internal debugging on and off by passing either > 1 or 0.
User-Agent => HTTP-MHTTP1/0,
Host => localhost,
Accept-Language => en-gb,
pass in header/value pairs that will be set on the next http_call().
http_body("this is the body");
Set the body of the next request via http_call().
my $rc = http_call("GET", "http://localhost");
Do an http request. Returns either < 0 or 1 depending on whether the call was
successful - remember to still check the http_status() code though.
Value < 0 are:
-1 : an invalid action (HTTP verb) was supplied
-2 : must supply an action (HTTP verb)
-3 : must supply a url
-4 : url must start with http:// or https://
-5 : write of headers to socket failed
-6 : write of data to socket was short
-7 : failed to write last line to socket
-8 : something wrong with the Conent-Length header
-11 : SSL_CTX_new failed - abort everything
-12 : SSL_new failed - abort everything
-13 : SSL_connect failed - abort everything
-14 : SSL_get_peer_certificate failed - abort everything
-15 : X509_get_subject_name failed - abort everything
-16 : X509_get_issuer_name failed - abort everything
-17 : cant find the next chunk for Transfer-encoding
-18 : cant find end headers
-19 : You must supply a Host header for HTTP/1.1
Returns the last status code.
Returns the last reason code.
Returns the headers of the last call, as a single string.
Returns the split out array ref of array ref header value pairs of the last call.
[ [ hdr, val], [hdr, val] ... ]
Returns the length of the body of the last call.
Returns the body of the last call.
my $pass = basic_authorization($user, $password);
Construct the basic authorization value to be passed in an Authorization