I'm using express 2.5.8 (not that I want to), and node 0.8.15 (again, I'd love to upgrade).
Here's my piece of code:
unless apiKey
res.writeHead 400, { "Content-Type": "text/plain" }
res.end "API key must be provided for API access."
return
EDIT: I broke up writeHead into statusCode and setHeader, and everything worked. Anyone know why?
working code:
unless apiKey
res.statusCode = 400
res.setHeader "Content-Type", "text/plain"
res.end "API key must be provided for API access."
return
END EDIT
I know this is being executed, and return works, because when I try
unless apiKey
res.end('wtf')
return
res.writeHead 400, { "Content-Type": "text/plain" }
res.end "API key must be provided for API access."
return
I do get the 'wtf' without server crashing.
When I try
unless apiKey
res.writeHead 400, { "Content-Type": "text/plain" }
return
res.end "API key must be provided for API access."
return
I wait forever and get a timeout, so the writeHead part works, and when I try
unless apiKey
# res.writeHead 400, { "Content-Type": "text/plain" }
res.end "API key must be provided for API access."
return
I also get the right response.
So why can't the original code work???