From 95381d7d2ccf05a6590712f2f62d18d9b7dec823 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 28 Nov 2008 16:46:08 +0000 Subject: [PATCH] * Make HEAD requests work when doing Nix closure downloads. --- src/Hydra/lib/Hydra/Controller/Root.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Hydra/lib/Hydra/Controller/Root.pm b/src/Hydra/lib/Hydra/Controller/Root.pm index ca88f4a6..bfcb53a7 100644 --- a/src/Hydra/lib/Hydra/Controller/Root.pm +++ b/src/Hydra/lib/Hydra/Controller/Root.pm @@ -146,7 +146,7 @@ sub showAllBuilds { my ($c, $baseUri, $page, $builds) = @_; $c->stash->{template} = 'all.tt'; - $page = int($page) || 1; + $page = (defined $page ? int($page) : 1) || 1; my $resultsPerPage = 50; @@ -756,6 +756,12 @@ sub closure :Local { $c->stash->{current_view} = 'Hydra::View::NixClosure'; $c->stash->{storePath} = $product->path; $c->stash->{name} = $build->nixname; + + # !!! quick hack; this is to make HEAD requests return the right + # MIME type. This is set in the view as well, but the view isn't + # called for HEAD requests. There should be a cleaner solution... + $c->response->content_type('application/x-nix-export'); + $c->response->header('Content-Disposition' => 'attachment; filename=' . $c->stash->{name} . '.closure.gz'); }