HTTP-GHTTP - Re: - example with ghttp -

Posted on Thu Sep 27 20:22:50 2007 by dstory in response to 130 (See the whole thread of 2)
Re: - example with ghttp -
use strict; use HTTP::GHTTP qw/:methods/; # # Post (data) to the specified (url). sub post_data { my ($url, $data) = @_; my $err = 0; my $r = HTTP::GHTTP->new($url, Connection => 'close'); if ($r) { $r->set_type(METHOD_POST); $r->set_body($data); $r->prepare(); $r->process_request(); my ($num, $msg) = $r->get_status(); if ($num != 200) { $err = 1; print("Post failed with: $num $msg\n"); } else { print("Posted\n"); } } else { $err = 2; print("Post failed\n"); } return $err; }
Write a response