aiohttp-debugtoolbar icon indicating copy to clipboard operation
aiohttp-debugtoolbar copied to clipboard

Update README.rst to clarify this won't work until the response contains a valid html document

Open NewUserHa opened this issue 3 years ago • 9 comments

What do these changes do?

clarify when this middleware work. related: https://docs.pylonsproject.org/projects/pyramid-debugtoolbar/en/latest/#usage

Are there changes in behavior for the user?

No

Related issue number

N/A

Checklist

  • [x] I think the code is well written
  • [x] Unit tests for the changes exist
  • [x] Documentation reflects the changes
  • [ ] Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> (e.g. 588.bugfix)
    • if you don't have an issue_id change it to the pr id after creating the PR
    • ensure type is one of the following:
      • .feature: Signifying a new feature.
      • .bugfix: Signifying a bug fix.
      • .doc: Signifying a documentation improvement.
      • .removal: Signifying a deprecation or removal of public API.
      • .misc: A ticket has been closed, but it is not of interest to users.
    • Make sure to use full sentences with correct case and punctuation, for example: Fix issue with non-ascii contents in doctest text files.

NewUserHa avatar Feb 12 '22 23:02 NewUserHa

I think the only difference is that the button won't be injected if the response is not HTML. The rest of the features should continue to work, like catching redirects, showing exceptions etc. I think it should be fairly obvious to a developer that the button will not be inserted if there isn't a web page to insert it into, so I'd prefer to avoid using documentation space explaining that.

Dreamsorcerer avatar Feb 13 '22 00:02 Dreamsorcerer

for aiohttp.web, the common case is that the users write APIs. And for small tests, the users may try to return a simple response with text='' and content_type='text/html', which is readable to most of the browsers but not aiohttp-debugtoolbar.

So the readme.rst could probably note the users what the middleware requires as the pyramid do.

the readme.rst should be to display a icon instead of current to work probably.

NewUserHa avatar Feb 13 '22 12:02 NewUserHa

Maybe we should actually still inject it even if it is missing </head|body> tags?

Dreamsorcerer avatar Feb 13 '22 12:02 Dreamsorcerer

agree. But why does pyramid require the closing tags?

NewUserHa avatar Feb 13 '22 12:02 NewUserHa

Probably because it's the sensible place to put it. Without those markers, we will end up creating invalid HTML. But, browsers will generally still parse the invalid HTML just fine (e.g. aiohttp-devtools currently injects code into an invalid location, but still works).

I'd suggest we try to inject into the tag, then check if it failed and append to the end otherwise.

Dreamsorcerer avatar Feb 13 '22 12:02 Dreamsorcerer

good idea. I tested flask_debugtoolbar and pyramid-debugtoolbar, both of them can't display the toolbar without the closing tags. probably they can improve too.

NewUserHa avatar Feb 13 '22 21:02 NewUserHa

BTW, I found the style of the toolbar/fixed panel of django-debug-toolbar and flask_debugtoolbar looks good and is more convenient than this aiohttp one.

NewUserHa avatar Feb 13 '22 21:02 NewUserHa

I'm currently refactoring much of the templates/js to make it work correctly with a CSP. But, after that, feel free to propose any changes for styling etc.

Dreamsorcerer avatar Feb 13 '22 22:02 Dreamsorcerer

cool!

django-debug-toolbar and flask_debugtoolbar way style is like a single page app. However, aiohttp-debugtoolbar is a button to go to a new tab.

NewUserHa avatar Feb 13 '22 22:02 NewUserHa