node-http-server
Advanced tools
Comparing version 8.0.0 to 8.1.0
{ | ||
"name": "node-http-server", | ||
"version": "8.0.0", | ||
"version": "8.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.", | ||
@@ -8,4 +8,4 @@ "main": "server/Server.js", | ||
"example": "example", | ||
"doc":"docs", | ||
"lib":"server" | ||
"doc": "docs", | ||
"lib": "server" | ||
}, | ||
@@ -20,9 +20,7 @@ "engines": { | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"basic": "node ./example/basic/basicApp.js", | ||
"https": "node ./example/basic/https-ONLY-basicApp.js", | ||
"both": "node ./example/basic/https-basicApp.js", | ||
"template":"node ./example/advanced/basicTemplate.js", | ||
"cluster":"node ./example/basic/cluster-basicApp.js", | ||
"template": "node ./example/advanced/basicTemplate.js", | ||
"cluster": "node ./example/basic/cluster-basicApp.js", | ||
"docs": "docco-plus ./README.md ./example/* ./example/**/* ./server/* ./bin/* ./local-certs/* " | ||
@@ -29,0 +27,0 @@ }, |
@@ -114,2 +114,21 @@ Node http server with https and proxy support | ||
## request uri, query, and, body | ||
For handling api requests, posts, puts patches etc with body data, we are now making that available on the request as both a ` String ` and ` Buffer ` incase you need images or videos uploaded. | ||
|key|type |value| | ||
|---|-----|-----| | ||
|request.body| string | request body | | ||
|request.url| string | processed uri | | ||
|request.uri| object | parsed url information and query | | ||
|request.serverRoot| string | local dir for publicly served data | | ||
|key|type |value| | ||
|---|-----|-----| | ||
|uri.protocol |string| protocol of request| | ||
|uri.host |string| hostname for domain| | ||
uri.hostname |string| hostname for domain| | ||
|uri.query |object| parsed querystring| | ||
|uri.port |number| port request was received on| | ||
### [Server Methods](http://riaevangelist.github.io/node-http-server/server/Server.js.html) | ||
@@ -116,0 +135,0 @@ |
@@ -147,3 +147,3 @@ 'use strict'; | ||
// #### onRawRequest | ||
// #### onRequest | ||
// | ||
@@ -734,26 +734,49 @@ // ` server.onRequest ` | ||
//return any value to force or specify delayed or manual serving | ||
if( | ||
this.onRequest( | ||
request, | ||
response, | ||
completeServing.bind(this) | ||
) | ||
){ | ||
return; | ||
}; | ||
request.body=''; | ||
const filename = path.join( | ||
request.serverRoot, | ||
request.url | ||
); | ||
request.on( | ||
'data', | ||
function(chunk){ | ||
request.body+=chunk; | ||
}.bind(this) | ||
).on( | ||
'end', | ||
function(){ | ||
if(this.config.verbose){ | ||
console.log(`###REQUEST BODY : | ||
${request.body} | ||
### | ||
`); | ||
} | ||
fs.exists( | ||
filename, | ||
function fileExists(exists){ | ||
this.serveFile(filename,exists,request,response); | ||
}.bind(this) | ||
requestBodyComplete.bind(this,request,response)(); | ||
}.bind(this) | ||
); | ||
} | ||
function requestBodyComplete(request,response){ | ||
//return any value to force or specify delayed or manual serving | ||
if( | ||
this.onRequest( | ||
request, | ||
response, | ||
completeServing.bind(this) | ||
) | ||
){ | ||
return; | ||
}; | ||
const filename = path.join( | ||
request.serverRoot, | ||
request.url | ||
); | ||
fs.exists( | ||
filename, | ||
function fileExists(exists){ | ||
this.serveFile(filename,exists,request,response); | ||
}.bind(this) | ||
); | ||
} | ||
module.exports=new Server; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
949902
11090
782