added a http post testing tool

git-svn-id: http://repo.ham.fi/svn/aprsc/trunk@524 3ce903b1-3385-4e86-93cd-f9a4a239f7ac
This commit is contained in:
Heikki Hannikainen 2012-07-29 19:29:11 +00:00
parent 079eae8aa0
commit f09f6318c3
2 changed files with 34 additions and 1 deletions

View File

@ -37,7 +37,7 @@ $ua->agent(
# test ###########################
my $data = "TEST>HTAPRS,TCPIP*:>http packet content";
my $out = "TEST>HTAPRS,TCPIP*,qAU,TESTING:>http packet content";
my $out = "TEST>HTAPRS,TCPIP*,qAC,TESTING:>http packet content";
my $post = "user TEST pass 29939 vers httpaprstester 1.0\r\n"
. "$data\r\n";
my $url = "http://127.0.0.1:55080/";

33
tools/aprsis-http-post Normal file
View File

@ -0,0 +1,33 @@
#!/usr/bin/perl
use LWP;
use LWP::UserAgent;
use HTTP::Request::Common;
my $ua = LWP::UserAgent->new;
$ua->agent(
agent => "httpaprstester/1.0",
timeout => 10,
max_redirect => 0,
);
# test ###########################
my $data = "TEST>HTAPRS,TCPIP*:>http packet content";
my $out = "TEST>HTAPRS,TCPIP*,qAC,TESTING:>http packet content";
my $post = "user TEST pass 29939 vers httpaprstester 1.0\r\n"
. "$data\r\n";
my $url = "http://127.0.0.1:55080/";
my $req = HTTP::Request::Common::POST($url);
$req->header('Accept-Type', 'text/plain'); # wat?
#$req->header('Accept', 'text/plain'); # this is what HTTP uses, really
$req->header('Content-Type', 'application/octet-stream');
$req->header('Content-Length', length($post));
$req->content($post);
my $res = $ua->simple_request($req);
print $res->code . " " . $res->message . "\n\n";
print $res->content . "\n";