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

Add response hook #2605

Closed
wants to merge 41 commits into from
Closed

Conversation

dadocsis
Copy link

@dadocsis dadocsis commented Dec 12, 2017

Are there changes in behavior for the user?

None

Related issue number

#434

Checklist

  • I think the code is well written
  • [x ] Unit tests for the changes exist
  • [ x] Documentation reflects the changes
  • [ x] If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • [ x] Add a new news fragment into the CHANGES folder
    • name it <issue_id>.<type> for example (588.bug)
    • 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."

@codecov-io
Copy link

codecov-io commented Dec 12, 2017

Codecov Report

Merging #2605 into master will increase coverage by 0.02%.
The diff coverage is 98.24%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #2605      +/-   ##
=========================================
+ Coverage   97.87%   97.9%   +0.02%     
=========================================
  Files          38      38              
  Lines        7304    7355      +51     
  Branches     1263    1278      +15     
=========================================
+ Hits         7149    7201      +52     
+ Misses         51      50       -1     
  Partials      104     104
Impacted Files Coverage Δ
aiohttp/web_request.py 99.68% <ø> (ø) ⬆️
aiohttp/http_writer.py 99.42% <ø> (+1.07%) ⬆️
aiohttp/web_runner.py 100% <ø> (ø)
aiohttp/web_response.py 98.18% <ø> (-0.08%) ⬇️
aiohttp/test_utils.py 98.57% <100%> (+0.01%) ⬆️
aiohttp/web.py 98.76% <100%> (ø) ⬆️
aiohttp/web_app.py 98.81% <100%> (ø) ⬆️
aiohttp/payload.py 98.74% <100%> (+0.02%) ⬆️
aiohttp/web_fileresponse.py 97.88% <100%> (-0.05%) ⬇️
aiohttp/web_protocol.py 89.42% <100%> (-0.11%) ⬇️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94e6ee5...d7df00a. Read the comment docs.

@asvetlov
Copy link
Member

I dislike the proposal by 2 reasons:

  1. Named hooks are too subtle. I understand, requests uses this approach but if we need a hook for calling a code just after retrieving response header -- let's add just it without inviting very generic and potentially error-prone approach.
  2. The PR calls auth helper passing ClientRequest instance. ClientRequest is not designed to be a part of public API, it is not stable and changed very often. I don't like the class design but can live with it unless we don't expose the class.

@hellysmile
Copy link
Member

It looks like solution for implementing aio-libs/aioelasticsearch#48 , requests has https://pypi.python.org/pypi/requests-aws4auth , right now it is very tricky to implement something like requests-aws4auth for aiohttp

@dadocsis
Copy link
Author

@asvetlov
Just want to clarify
#1. So just create a single static hook?
#2. I see what you are saying about it not being apart of the api. Unfortunately non trivial auth schemes will need the original request object. Do you have an actionable suggestion for me?

* Drop encoding param

* Add CHANGES
@asvetlov
Copy link
Member

Please give me a pause.
I'll try to cook something.

I understand the need and share the intention, but maybe I can invent an alternative implementation.

asvetlov and others added 17 commits December 14, 2017 07:47
* Support .netrc by trust_env
* Avoid to create unnecessary resources (aio-libs#2586)

Do not create a new resource when adding a route with the same
name and path of the last added resource.

* Add a test for AbstractResource().raw_match()

* PrefixResource().raw_match() should always return False
…s#2611)

* Add support to Flask-style decorators with class-based Views

* Add versionadded 3.0 in documentation
…bs#2612)

Before this commit, the TCP tunning was allowed from PayloadWriter
and Response classes, this was exclusively used by just some edge cases and
caused some overhead in performance and maintainability.

Since now, the TCP tunning has to be done using the stream and its
the responsibility of the developer set and set back the proper values.
* allow custom port to TestServer

* tweaks and add CHANGES

* add docs

* add docs for pytest fixture unused_port

* addinv versionadded:: 3.0
@Cellebyte
Copy link

Will this be merged? I need this to implement some custom auth handlers for OpenID token-exchange client Authorization and Authentication in my async client implementation.

@asvetlov
Copy link
Member

I understand your needs but the functionality should be implemented in a slightly different way than proposed by this PR.

@asvetlov asvetlov closed this Jan 29, 2019
@Cellebyte
Copy link

How do I implement it now? Should I use decorators?

@asvetlov
Copy link
Member

Now there is the inconvenient and undocumented way with passing request_class to ClientSession constructor.
The functionality will be changed/removed in aiohttp 3.5, sorry -- after implementing the proper solution.

@Cellebyte
Copy link

OK, so i do it the messy way. Thanks

@asvetlov
Copy link
Member

Sorry about that.
I really want to improve things, it is on my todo list.
The solution touches several aspects, it is not 20-lines change.
I hope to introduce something in a month or two.

@lock lock bot added the outdated label Jan 30, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jan 30, 2020
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Jan 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bot:chronographer:provided There is a change note present in this PR outdated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants