Skip to content
Browse files

Don't return empty 204 instead of 404

This happen when x-proxy-capabilities are set to reproxy-file but the
requested file doesn't exist.
  • Loading branch information...
1 parent 7b5ab39 commit 1b410d326280ce72faa95f9a1255156f830fcf08 @yannk committed
Showing with 10 additions and 5 deletions.
  1. +3 −0 Changes
  2. +7 −5 lib/MogileFS/REST.pm
View
3 Changes
@@ -1,3 +1,6 @@
+0.04 Tue Aug 2 11:00:00 2012
+ - Don't return empty 204 instead of a 404 when file doesn't exist
+
0.03 Tue Jul 3 12:00:00 2012
- Fix 200 response with empty body for ?paths when file doesn't exist.
View
12 lib/MogileFS/REST.pm
@@ -108,8 +108,14 @@ sub get {
}
my $client = $app->get_client($domain);
my $res = $req->new_response(HTTP_OK);
+
+ ## so, where is this file?
+ my @paths = $client->get_paths($key, { no_verify => 1 });
+ unless (@paths) {
+ ## nowhere
+ return $req->new_response(HTTP_NOT_FOUND);
+ }
if ($can_reproxy) {
- my @paths = $client->get_paths($key, { no_verify => 1 });
$res->header('X-Reproxy-URL' => join " ", @paths);
## we can reproxy, so just send headers without any body
$app->debug("reproxying to " . $res->header('X-Reproxy-URL'));
@@ -121,10 +127,6 @@ sub get {
if ($req->method eq 'HEAD') {
## deprecated. backward compat only
- my @paths = $client->get_paths($key, { no_verify => 1 });
- unless (@paths) {
- return $req->new_response(HTTP_NOT_FOUND);
- }
$res->header('X-Reproxy-URL' => join " ", @paths);
if ($can_reproxy) {
$app->warn("If you want to get paths use GET /d/k?paths instead");

0 comments on commit 1b410d3

Please sign in to comment.
Something went wrong with that request. Please try again.