Skip to content

Refactor the way how Payload headers are handled#3479

Merged
asvetlov merged 3 commits intoaio-libs:masterfrom
kxepal:3035-refactor-payload-headers
Jan 5, 2019
Merged

Refactor the way how Payload headers are handled#3479
asvetlov merged 3 commits intoaio-libs:masterfrom
kxepal:3035-refactor-payload-headers

Conversation

@kxepal
Copy link
Copy Markdown
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
Copy Markdown
Member

asvetlov commented Jan 3, 2019

Please fix flake8

@codecov-io
Copy link
Copy Markdown

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
Copy Markdown
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? :)

@kxepal
Copy link
Copy Markdown
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 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
Copy Markdown
Member Author

kxepal commented Jan 4, 2019

@asvetlov Ok, it's ready for review.

@kxepal
Copy link
Copy Markdown
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.

kxepal added 3 commits January 5, 2019 00:45
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
Copy Markdown

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