Permalink
Browse files

return original content and response header from cache

  • Loading branch information...
1 parent aa33a68 commit 4d3937772bf30c00d03877ba4b267a8dbc79ab7d @sekimura committed Oct 7, 2011
Showing with 2 additions and 6 deletions.
  1. +1 −5 lib/LWP/UserAgent/WithCache.pm
  2. +1 −1 t/10_request.t
@@ -68,11 +68,7 @@ sub request {
## return cached data if it is "Not Modified"
if ($res->code eq HTTP::Status::RC_NOT_MODIFIED) {
- my $not_modified_res = HTTP::Response->parse($obj->{as_string});
- # hrm.. should we use '200 OK' here?
- $not_modified_res->code(HTTP::Status::RC_NOT_MODIFIED);
- $not_modified_res->message(HTTP::Status::status_message(HTTP::Status::RC_NOT_MODIFIED));
- return $not_modified_res;
+ return HTTP::Response->parse($obj->{as_string});
}
## cache only "200 OK" content
View
@@ -100,6 +100,6 @@ local *LWP::UserAgent::request = sub {return $not_modified_res};
my $cached_res = $ua->get('http://www.example.com/styles.css');
-is ($cached_res->code, 304);
+is ($cached_res->code, 200);
is ($cached_res->content, $res->content);
}

0 comments on commit 4d39377

Please sign in to comment.