Issue
Heroku router records unexpected errors like H17 - Poorly formatted HTTP response for my app. I want to know what is wrong.
Resolution
It is possible to run the app and send requests to the app on a single one-off dyno.
- Establish a bash session on a one-off dyno for the app:
heroku run bash -a <app-name>, - Run the web server for the app on the one-off dyno with the command defined in the
Procfileforwebdynos, e.g.,bundle exec rails server, - Send the web server to the background on the bash session with typing Ctrl-z and running the
bgcommand, and - Send a request to the web server with the
curlcommand from the same bash session on the one-off dyno, e.g.,curl -i http://localhost:$PORT. Depending upon how the app is configured, it may be necessary to add, e.g., theX-Forwarded-Proto: httpsrequest header, to mimic that the request came through HTTPS:curl -i -H 'X-Forwarded-Proto: https' http://localhost:$PORT. Then, - Inspect the response header printed by the
curlcommand.
If it is necessary to send other request headers as browsers do, it is possible to start with "Copy" the request "as cURL" from the Network tab in the developer tools on your browser, replace the scheme and host parts of the URL with http://localhost:$PORT and adding, e.g., the X-Forwarded-For request header with adding the command line option -H 'X-Forwarded-Proto: https'. Please be careful not to leak sensitive information like session tokens.
When done, terminate the one-off dyno with exiting from the bash session.