NAME
HTTP::MHTTP - this library provides reasonably low level access to the HTTP protocol, for perl. This does not replace LWP but is a cut for speed.
SYNOPSIS
use HTTP::MHTTP;
http_init();
http_add_headers( 'User-Agent' => 'DVSGHTTP1/1', 'Accept-Language' => 'en-gb', 'Connection' => 'Keep-Alive', ); if (http_call("GET", "http://localhost")){ if (http_status() == 200 ){ print http_response(); } else { print "MSG: ".http_reason(); } } else { print "call failed \n"; }
DESCRIPTION
A way faster http access library that uses C extension based on mhttp to do the calls.
http_init()
initialise the mhttp library - must be called once to reset all internals, use http_reset() if you don't need to reset your headers before the next call.
http_reset()
reset the library internals for everything except the headers specified previously, and the debug switch. Call http_init() if you need to reset everything.
switch_debug()
switch_debug(<0 || 1>)
Toggle the internal debugging on and off by passing either > 1 or 0.
http_add_headers()
http_add_headers(
'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()
http_body("this is the body");
Set the body of the next request via http_call().
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.
http_status()
Returns the last status code.
http_reason()
Returns the last reason code.
http_headers()
Returns the headers of the last call, as a single string.
http_split_headers()
Returns the split out hash of headers of the last call. Returns the hash reference.
http_response_length()
Returns the length of the body of the last call.
http_response()
Returns the body of the last call.
basic_authorization()
my $pass = basic_authorization($user, $password);
Construct the basic authorization value to be passed in an "Authorization" header.
COPYRIGHT
Copyright (c) 2003, Piers Harding. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.
AUTHOR
Piers Harding, piers@ompa.net.
SEE ALSO
perl(1)