mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-18 10:34:50 +08:00
[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:
parent
73725afbe7
commit
67fb8bed5c
1 changed files with 8 additions and 0 deletions
|
@ -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}\" "
|
||||
|
|
Loading…
Add table
Reference in a new issue