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

Refactor the way how Payload headers are handled #3479

Merged
merged 3 commits into from
Jan 5, 2019

Conversation

kxepal
Copy link
Member

@kxepal kxepal commented Jan 3, 2019

This change actually solves three separated, but heavy coupled
issues:

  1. Payload.content_type may conflict with Payload.headers[CONTENT_TYPE].

While in the end priority goes to the former one, it seems quite strange that
Payload object may have dual state about what content type it contains.

  1. IOPayload respects Content-Disposition which comes with headers.

This is part of #3035 issue.

  1. ClientRequest.skip_autoheaders now filters Payload.headers as well.

This issue was eventually found due to refactoring: Payload object
may setup some autoheaders, but those will bypass skip logic.

@asvetlov
Copy link
Member

asvetlov commented Jan 3, 2019

Please fix flake8

@kxepal kxepal force-pushed the 3035-refactor-payload-headers branch 3 times, most recently from 4548688 to ba5bf63 Compare January 4, 2019 14:18
@codecov-io
Copy link

codecov-io commented Jan 4, 2019

Codecov Report

Merging #3479 into master will increase coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3479      +/-   ##
==========================================
+ Coverage   97.91%   97.95%   +0.04%     
==========================================
  Files          44       44              
  Lines        8567     8553      -14     
  Branches     1383     1377       -6     
==========================================
- Hits         8388     8378      -10     
+ Misses         74       71       -3     
+ Partials      105      104       -1
Impacted Files Coverage Δ
aiohttp/client_reqrep.py 97.44% <100%> (ø) ⬆️
aiohttp/multipart.py 96.09% <100%> (+0.62%) ⬆️
aiohttp/payload.py 98.6% <100%> (-0.04%) ⬇️
aiohttp/web_response.py 98.19% <0%> (-0.23%) ⬇️
aiohttp/test_utils.py 99.35% <0%> (+0.32%) ⬆️

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 075c705...74ad55e. Read the comment docs.

Copy link
Member

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you add a test or two? :)

aiohttp/payload.py Outdated Show resolved Hide resolved
@kxepal
Copy link
Member Author

kxepal commented Jan 4, 2019

Would you add a test or two? :)

Yes, I'm trying to do this around the day, but getting distraction by various things. Once finish with them will remove WIP status. Stay tuned!

@kxepal kxepal force-pushed the 3035-refactor-payload-headers branch 2 times, most recently from 73194ac to 0f71731 Compare January 4, 2019 17:09
@kxepal kxepal changed the title WIP: Refactor the way how Payload headers are handled Refactor the way how Payload headers are handled Jan 4, 2019
@kxepal
Copy link
Member Author

kxepal commented Jan 4, 2019

@asvetlov Ok, it's ready for review.

@kxepal kxepal force-pushed the 3035-refactor-payload-headers branch from 66ccd6e to 74ad55e Compare January 4, 2019 21:43
@kxepal
Copy link
Member Author

kxepal commented Jan 4, 2019

Rebased with conflict fix. Also noticed that Travis CI and AppVeyor has different opinion about .py files MIME type. Probably, there could be other differences as well.

This change actually solves three separated, but heavy coupled
issues:

1. `Payload.content_type` may conflict with `Payload.headers[CONTENT_TYPE]`.

While in the end priority goes to the former one, it seems quite strange that
Payload object may have dual state about what content type it contains.

2.IOPayload respects Content-Disposition which comes with headers.

3. ClientRequest.skip_autoheaders now filters Payload.headers as well.

This issue was eventually found due to refactoring: Payload object
may setup some autoheaders, but those will bypass skip logic.
On Linux it detects py-file as `text/x-python`, but on Windows CI just
as `text/plain`.
@asvetlov asvetlov merged commit c9dabcb into aio-libs:master Jan 5, 2019
asvetlov pushed a commit that referenced this pull request Jan 5, 2019
* Refactor the way how Payload headers are handled

This change actually solves three separated, but heavy coupled
issues:

1. `Payload.content_type` may conflict with `Payload.headers[CONTENT_TYPE]`.

While in the end priority goes to the former one, it seems quite strange that
Payload object may have dual state about what content type it contains.

2.IOPayload respects Content-Disposition which comes with headers.

3. ClientRequest.skip_autoheaders now filters Payload.headers as well.

This issue was eventually found due to refactoring: Payload object
may setup some autoheaders, but those will bypass skip logic.

* Update change notes

* Set Content-Type explicitly to avoid guessing issues

On Linux it detects py-file as `text/x-python`, but on Windows CI just
as `text/plain`.
@lock
Copy link

lock bot commented Jan 5, 2020

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Jan 5, 2020
@lock lock bot locked as resolved and limited conversation to collaborators Jan 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants