Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Correct headers for content-type and content-disposition

  • Loading branch information...
commit b07a07f94e9b36277918c55edb9b68638fdf2c76 1 parent 483bf84
@kriszyp authored
Showing with 27 additions and 5 deletions.
  1. +26 −4 lib/jsgi/archive.js
  2. +1 −1  public/submitted.html
View
30 lib/jsgi/archive.js
@@ -6,10 +6,32 @@ var Static = require("pintura/jsgi/static").Static,
module.exports = function(request){
return when(staticApp(request), function(response){
- if(response.status == 404 && request.pathInfo.substring(0,10) == "/archives/"){
- return when(cacheArchive(decodeURIComponent(request.pathInfo.substring(10))), function(){
- return staticApp(request);
- });
+ if(request.pathInfo.substring(0,10) == "/archives/"){
+ if(response.status == 404){
+ return when(cacheArchive(decodeURIComponent(request.pathInfo.substring(10))), function(){
+ return when(staticApp(request), function(response){
+ console.log("setting content type");
+ if(request.pathInfo.match(/zipball/)){
+ response.headers["content-type"] = "application/zip";
+ response.headers["content-disposition"] = "attachment; filename=package.zip"
+ }
+ if(request.pathInfo.match(/tarball/)){
+ response.headers["content-type"] = "application/x-gzip";
+ response.headers["content-disposition"] = "attachment; filename=package.tar.gz"
+ }
+ return response;
+
+ });
+ });
+ }
+ if(request.pathInfo.match(/zipball/)){
+ response.headers["content-type"] = "application/zip";
+ response.headers["content-disposition"] = "attachment; filename=package.zip"
+ }
+ if(request.pathInfo.match(/tarball/)){
+ response.headers["content-type"] = "application/x-gzip";
+ response.headers["content-disposition"] = "attachment; filename=package.tar.gz"
+ }
}
return response;
});
View
2  public/submitted.html
@@ -4,6 +4,6 @@
<title>Submitted a package</title>
</head>
<body>
- Your package was submitted, it may be a few minutes before all the depenendencies are downloaded.
+ Your package was submitted.
</body>
</html>
Please sign in to comment.
Something went wrong with that request. Please try again.