Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

return original content and response header from cache

  • Loading branch information...
commit 4d3937772bf30c00d03877ba4b267a8dbc79ab7d 1 parent aa33a68
Masayoshi Sekimura authored
Showing with 2 additions and 6 deletions.
  1. +1 −5 lib/LWP/UserAgent/WithCache.pm
  2. +1 −1  t/10_request.t
6 lib/LWP/UserAgent/WithCache.pm
View
@@ -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
2  t/10_request.t
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);
}
Please sign in to comment.
Something went wrong with that request. Please try again.