Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add some error checking.

  • Loading branch information...
commit f7f78c94f97c7494b3429d098e38cb5c55ef1460 1 parent e9fc5bd
@mythmon authored
Showing with 5 additions and 0 deletions.
  1. +5 −0 ears.js
View
5 ears.js
@@ -16,6 +16,11 @@ var server = http.createServer(function (req, res) {
req.addListener('data', function (chunk) { data += chunk; });
req.addListener('end', function () {
+ if (req.method != 'POST' || !data) {
+ res.writeHead(500);
+ res.end(JSON.stringify({"status": "what?"}));
+ return;
+ }
data = data.replace(/^payload=/, '');
data = decodeURIComponent(data);
data = JSON.parse(data);
Please sign in to comment.
Something went wrong with that request. Please try again.