[client-app] Specify Content-Type in developer bar curl commands

Summary:
Dunno if I'm the only one having this problem, but I spent at least an
hour over the last two days wondering why hapi just sits there and hangs
in the Joi validation step when I copy-paste calls to /auth from the
developer bar to my terminal. It turns out that if you fail to send the
correct Content-Type when sending a JSON payload, Joi just hangs
forever. (WTF!)

Test Plan: manual

Reviewers: halla, evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4204
This commit is contained in:
Christine Spang 2017-03-13 11:33:16 -07:00
parent 73725afbe7
commit 67fb8bed5c

View file

@ -26,6 +26,14 @@ class DeveloperBarCurlRequest
for k,v of request.headers
headers += "-H \"#{k}: #{v}\" "
# When constructed during _onWillMakeAPIRequest(), `request` has not been
# processed by node-request yet. Therefore, it will not have Content-Type
# set in the request headers.
if (request.json and not request._json and
'content-type' not in request.headers and
'Content-Type' not in request.headers)
headers += '-H "Content-Type: application\/json" '
if request.auth?.bearer
tok = request.auth.bearer.replace("!", "\\!")
headers += "-H \"Authorization: Bearer #{tok}\" "