Skip to content
Browse files

server: DRY HTML_HEADERS

  • Loading branch information...
1 parent e3ba859 commit d3bbed00372e3404ad73c51fd7746da9654c6e23 @astro astro committed
Showing with 4 additions and 3 deletions.
  1. +4 −3 server.js
View
7 server.js
@@ -6,8 +6,9 @@ var template = require('./template');
var MAX_FILE_SIZE = 100 * 1024 * 1024;
function app(app) {
+ var HTML_HEADERS = { 'Content-Type': 'text/html; charset=UTF-8' };
app.get('/', function(req, res) {
- res.writeHead(200, { 'Content-Type': 'text/html' });
+ res.writeHead(200, HTML_HEADERS);
res.write(template.htmlHead);
res.write(template.uploadForm);
res.write(template.downloadList(files.getFiles()));
@@ -57,13 +58,13 @@ function app(app) {
req.on('end', function() {
if (error) {
console.error(error.stack);
- res.writeHead(400, { 'Content-Type': 'text/html' });
+ res.writeHead(400, HTML_HEADERS);
res.write(template.htmlHead);
res.write(template.error(error || new Error('No file received')));
res.write(template.htmlFoot);
res.end();
} else {
- res.writeHead(200, { 'Content-Type': 'text/html' });
+ res.writeHead(200, HTML_HEADERS);
res.write(template.htmlHead);
res.write(template.thanks);
res.write(template.htmlFoot);

0 comments on commit d3bbed0

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