Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add `Content-Type` header support to `bem server`

  • Loading branch information...
commit 61c3be5b6713b7467405fbfddc42ccd90970f067 1 parent 638f72e
@arikon arikon authored
Showing with 7 additions and 2 deletions.
  1. +6 −2 lib/server.js
  2. +1 −0  package.json
View
8 lib/server.js
@@ -3,6 +3,7 @@ var Q = require('q'),
QHTTP = require('q-http'),
QS = require('querystring'),
UTIL = require('util'),
+ MIME = require('mime'),
PATH = require('./path'),
MAKE = require('./make');
@@ -73,7 +74,9 @@ function requestHandler(root, runner) {
// try to find node in graph
console.log(UTIL.format('*** searching for node "%s"', relPath));
return runner.findNode(relPath)
- .fail(function(){})
+ .fail(function() {
+ console.log(UTIL.format('*** not found "%s"', relPath));
+ })
.then(function(id) {
if (!id) return;
@@ -130,6 +133,7 @@ function processDirectory(response, path) {
return QFS.list(path).then(function(list) {
response.status = 200;
response.charset = 'utf8';
+ response.headers = { 'content-type': 'text/html' };
var body = response.body = [];
@@ -176,9 +180,9 @@ function processDirectory(response, path) {
function streamFile(response, path) {
return function() {
- // FIXME: content-type
response.status = 200;
response.charset = 'binary';
+ response.headers = { 'content-type': MIME.lookup(path) };
response.body = QFS.open(path);
return response;
View
1  package.json
@@ -34,6 +34,7 @@
"qq": "~0.3.4",
"q-fs": "0.1",
"q-http": "~0.1.13",
+ "mime": "~1.2.5",
"underscore": "~1.3.1",
"inherit": "~1.0.0",
"borschik": "~0.0.7",
Please sign in to comment.
Something went wrong with that request. Please try again.