Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plain text output for command line user agents #88

Open
samuelcolvin opened this issue Jan 12, 2017 · 3 comments
Open

Plain text output for command line user agents #88

samuelcolvin opened this issue Jan 12, 2017 · 3 comments

Comments

@samuelcolvin
Copy link
Member

I've just been building a restful API and am testing it with curl.

I have debugtoolbar enabled and 500 errors come through as a full web page which isn't at all easy to read.

The obvious solution is to disable debugtoolbar but it would still be nice to show plain text output for obvious CLI requests eg. curl, wget, httpie in case people use curl with dbtb switched on.

Alternatively there could be a white list of browser user-agents to show HTML response for or use content-type, but that all seems error prone.

@jettify
Copy link
Member

jettify commented Jan 12, 2017

Good idea, would you like to create PR with content type check?

@jettify
Copy link
Member

jettify commented Jan 12, 2017

also there is option that can disable interception of exception

intercept_exc = app[APP_KEY]['settings']['intercept_exc']

@samuelcolvin
Copy link
Member Author

I'll create a PR if I get a chance, however I really think User-Agent is a better field to decide with than Content-Type.

  1. That's kind of the point in User-Agent - to tell the server what kind of application is making the request.
  2. It's likely that when using CLI apps to make requests people will mess with the content-type as it's regularly used by servers to decide what to do.

In time I guess we could use content-type checking too, but let's do the simplest thing first then make it more complicated when we have to.

I also noticed that even with debugtoolbar switched off (or I guess exception interception disabled) the debug response from aiohttp is encoded as HTML (even if it's very simple) so this change would be useful even in that situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants