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:
parent
079eae8aa0
commit
f09f6318c3
|
|
@ -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/";
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
|
||||
Loading…
Reference in New Issue