Skip to content

Commit

Permalink
further uWS improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
schamberg97 committed Sep 8, 2020
1 parent 2b3459e commit 088996f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
24 changes: 17 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,14 +105,24 @@ var appCore = function (options, server, mounted) {
req.on('newListener', (event, listener) => {

if (event === 'end' && !req.bodyParsingDone) {
if (req.rUWS_internal.bodyParsed) {

req.bodyParsingDone = true
req.emit('data', req.rUWS_internal.body)
req.once('end', listener)
req.emit('end')
req.emit('close')
let timer
function checkParsed() {
if (req.rUWS_internal.bodyParsed) {

req.bodyParsingDone = true

req.emit('data', req.rUWS_internal.body)
req.once('end', listener)
req.emit('end')
req.emit('close')
if (timer) return clearInterval(timer)
return
}
else if (!timer) {
timer = setInterval(checkParsed, 250)
}
}
checkParsed()
}
});
return oldCoreHandle.apply(this, [req,res,step])
Expand Down
2 changes: 1 addition & 1 deletion lib/uwsCompat.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class HttpRequest {
this.method = uRequest.getMethod().toUpperCase()
this.statusCode = null
this.statusMessage = null
//this.rUWS_internal = {}
this.rUWS_internal = {}
//this.body = null
this.headers = {}

Expand Down

0 comments on commit 088996f

Please sign in to comment.