Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-http-server

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-http-server - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

package.json~

2

package.json
{
"name": "node-http-server",
"version": "2.0.0",
"version": "2.1.0",
"description": "A very simple and fast http server for node, bash, and spawnable from C, Python etc. It is lightweight and great for embedded solutions as well as everyday development or public facing apps.",

@@ -5,0 +5,0 @@ "main": "server/http.js",

@@ -10,4 +10,4 @@ Node http server

[![alt node-http-server npm stats](https://nodei.co/npm/node-http-server.png?downloads=true&downloadRank=true&stars=true)](https://npmjs.org/package/node-http-server)
[![alt node-http-server npm downloads](https://nodei.co/npm-dl/node-http-server.png "number of times the node-http-server package has been downloaded from npm")](https://npmjs.org/package/node-http-server)
[![alt node-http-server npm downloads](https://nodei.co/npm-dl/node-http-server.png "number of times the node-http-server package has been downloaded from npm")](https://npmjs.org/package/node-http-server)
[![http server package quality](http://npm.packagequality.com/badge/node-http-server.png)](http://packagequality.com/#?package=node-http-server)
This work is licenced via the [DBAD Public Licence](http://www.dbad-license.org/).

@@ -14,0 +14,0 @@

@@ -26,10 +26,10 @@ var http = require('http'),

/**************************************\
*
* These are the valid configs
*
* These are the valid configs
* that can be passed when deploying
* a server, content types are dynamic
* you can pass whatever you like
*
*
* ************************************/
function config(userConfig){

@@ -47,5 +47,5 @@ var config={

* domain : /that/domains/root/dir
*
*
* for sub domains, specify the whole host i.e. "my.sub.domain"
* you may need to edit your hosts file, cnames or iptable
* you may need to edit your hosts file, cnames or iptable
* domain or my.domain etc. goes to 127.0.0.1 for local development

@@ -72,3 +72,3 @@ * *****************/

restrictedType: {
},

@@ -85,3 +85,3 @@ errors:{

}
if(userConfig){

@@ -92,3 +92,3 @@ for(var k in userConfig){

}
function serverLogging(data){

@@ -99,3 +99,3 @@ fs.exists(

data.timestamp=new Date().getTime();
var JSONData=JSON.stringify(data);

@@ -105,15 +105,15 @@ var method='appendFile';

method='writeFile'
fs[method](
config.log,
JSONData,
config.log,
JSONData,
function (err) {
if(err)
if(err)
console.log(err);
}
);
);
}
);
}
return config;

@@ -128,11 +128,11 @@ };

server.config.logID='### '+server.config.domain+' server';
if(server.config.verbose)
console.log(server.config.logID+' configured with ###\n\n',server.config);
server.listen(server.config.port);
if(server.config.verbose)
console.log(server.config.logID+' listening on port '+server.config.port+' ###\n\n');
function serveFile(filename,exists,response) {

@@ -150,6 +150,6 @@ if(!exists) {

}
var contentType = path.extname(filename).slice(1);
//Only serve specified file types
//Only serve specified file types
if(!server.config.contentType){

@@ -166,3 +166,3 @@ if(server.config.verbose)

}
//default

@@ -174,3 +174,3 @@ if (

}
//Do not allow access to restricted file types

@@ -190,6 +190,6 @@ if (

}
fs.readFile(
filename,
'binary',
filename,
'binary',
function(err, file) {

@@ -207,10 +207,10 @@ if(err) {

}
var headers = {
'Content-Type' : server.config.contentType[contentType]
}
if(server.config.server.noCache)
headers['Cache-Control']='no-cache, no-store, must-revalidate';
serve(

@@ -223,6 +223,6 @@ response,

);
if(server.config.verbose)
console.log(server.config.logID+' 200 ###\n\n',headers,'\n\n');
return;

@@ -232,3 +232,3 @@ }

}
function serve(response,body,status,headers,encoding){

@@ -238,3 +238,3 @@ //defaults to 200

status=200;
//defaults to text/plain

@@ -245,13 +245,13 @@ if(!headers){

}
if(server.config.verbose)
console.log(server.config.logID+' headers not specified ###\n\nheaders set to:\n',headers,'\n\n');
}
//defaults to utf8
if(!encoding)
encoding='utf8';
response.writeHead(
status,
status,
headers

@@ -263,3 +263,3 @@ );

}
function requestRecieved(request,response){

@@ -272,7 +272,7 @@ if(server.config.log){

}
server.config.logFunction(
logData
);
if(server.config.verbose)

@@ -285,7 +285,9 @@ console.log(logData);

uri='/'+server.config.server.index;
var hostname= request.headers.host.split(':'),
root = server.config.root;
if(hostname[0]!=server.config.domain && server.config.domain!='0.0.0.0'){
var hostname= [];
if (request.headers.host != undefined)
hostname = request.headers.host.split(':');
var root = server.config.root;
if(hostname.length > 0 && hostname[0]!=server.config.domain && server.config.domain!='0.0.0.0'){
if(!server.config.domains[hostname[0]]){

@@ -297,3 +299,3 @@ serveFile(hostname[0],false,response);

}
if(server.config.verbose){

@@ -306,11 +308,11 @@ console.log(server.config.logID+' REQUEST ###\n\n',

}
if(uri.slice(-1)=='/')
uri+=server.config.server.index;
var filename = path.join(
root,
root,
uri
);
fs.exists(

@@ -323,4 +325,4 @@ filename,

}
return server;

@@ -332,2 +334,2 @@ }

configTemplate : config
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc