Subject: | PATCH: new tests for max_size and 206 responses |
Attached is a patch against the current "git" state that adds some more
tests for "max_size" and 206 http responses (all the the tests pass).
I was also curious to know if "206" would be returned in the case that
max_size was used, the max_size requested was greater than the size of
the document. But, that behavior is provided by the server, not
LWP::UserAgent, so we don't have control over it.
Subject: | new_partial_tests.patch |
diff --git a/t/local/http.t b/t/local/http.t
index 05c231e..5178116 100644
--- a/t/local/http.t
+++ b/t/local/http.t
@@ -48,7 +48,7 @@ else {
}
use Test;
-plan tests => 49;
+plan tests => 52;
my $greeting = <DAEMON>;
$greeting =~ /(<[^>]+>)/;
@@ -328,6 +328,34 @@ ok($_, qr/^Content-Type:\s*application\/x-www-form-urlencoded$/mi);
ok($_, qr/^foo=bar&bar=test$/m);
#----------------------------------------------------------------
+print "Check partial content response...\n";
+sub httpd_get_partial
+{
+ my($c) = @_;
+ $c->send_basic_header(206);
+ print $c "Content-Type: image/jpeg\015\012";
+ $c->send_crlf;
+ print $c "some fake JPEG content";
+
+}
+
+{
+ $req = HTTP::Request->new( GET => url("/partial", $base) );
+ $res = $ua->request($req);
+ ok($res->is_success); # "a 206 response is considered successful"
+}
+{
+ $ua->max_size(3);
+ $req = HTTP::Request->new( GET => url("/partial", $base) );
+ $res = $ua->request($req);
+ ok($res->is_success); # "a 206 response is considered successful"
+ # Put max_size back how we found it.
+ $ua->max_size(undef);
+ ok($res->as_string, qr/Client-Aborted: max_size/); # Client-Aborted is returned when max_size is given
+}
+
+
+#----------------------------------------------------------------
print "Terminating server...\n";
sub httpd_get_quit
{