#!/usr/bin/perl -T use Test::More tests => 8; use LWP::UserAgent qw(); require 'TestServer.pm'; my $pid = TestServer->new(12345)->background; my $ua = LWP::UserAgent->new; my $r; $r = $ua->request(HTTP::Request->new(GET => 'http://localhost:12345',)); ok $r->is_success; like $r->header('Content-Type'), qr(^application/xml); $r = $ua->request(HTTP::Request->new(GET => 'http://localhost:12345/pathinfoblahblah',)); ok $r->is_error; like $r->header('Content-Type'), qr(^text/plain); is $r->content, 'error'; my $post_data = 'some post data'; $r = $ua->request(HTTP::Request->new(POST => 'http://localhost:12345', ['Content-Type' => 'application/octet-stream'], $post_data,)); is $r->code, 201; ok $r->header('Location'); is $r->content, $post_data; kill 'KILL', $pid;