Skip to content

Commit

Permalink
Merge pull request pencilblue#1211 from pencilblue/issue/1208
Browse files Browse the repository at this point in the history
pencilblue#1208 Fixes issue where public content 404 was causing failure
  • Loading branch information
brianhyder authored Feb 1, 2017
2 parents 94de87b + 3c1e0a2 commit 4d02a96
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions include/http/request_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -670,20 +670,20 @@ module.exports = function RequestHandlerModule(pb) {
var self = this;
fs.readFile(absolutePath, function(err, content){
if (err) {

//TODO [1.0] change default content type to JSON and refactor public file serving so it falls inline with other controller functions
self.themeRoute = self.themeRoute || {};
self.themeRoute.content_type = 'application/json';
return self.serve404();
}

//build response structure
//guess at content-type
var data = {
content: content
content: content,
content_type: mime.lookup(absolutePath)
};

//guess at content-type
var mimeType = mime.lookup(absolutePath);
if (mimeType) {
data.content_type = mimeType;
}

//send response
self.writeResponse(data);
});
Expand Down Expand Up @@ -743,6 +743,9 @@ module.exports = function RequestHandlerModule(pb) {
return false;
}

//default the options object
options = options || {};

//bump the error count so handlers will know if we are recursively trying to handle errors.
this.errorCount++;

Expand Down

0 comments on commit 4d02a96

Please sign in to comment.