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

move typed headers and implement FromRequest #2094

Merged
merged 26 commits into from
Apr 1, 2021

Conversation

ibraheemdev
Copy link
Member

@ibraheemdev ibraheemdev commented Mar 19, 2021

PR Type

Refactor

PR Checklist

  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • A changelog entry has been made for the appropriate packages.
  • Format code with the latest stable rustfmt.
  • (Team) Label with affected crates and semver status.

Overview

  • Move common typed headers from actix-http into actix-web.
  • Add a Header extractor.
  • Refactor awc::TestResponse to use IntoHeaderPair. This is needed now that the typed headers have been moved from -http.

Closes #1837.

@ibraheemdev ibraheemdev force-pushed the header-from-request branch 2 times, most recently from 31cd96c to e6a7cfa Compare March 23, 2021 13:30
@ibraheemdev ibraheemdev added A-http project: actix-http A-web project: actix-web B-semver-major breaking change requiring a major version bump labels Mar 24, 2021
@ibraheemdev ibraheemdev marked this pull request as ready for review March 24, 2021 14:21
@ibraheemdev ibraheemdev requested review from a team March 24, 2021 14:22
Copy link
Member

@robjtede robjtede left a comment

Choose a reason for hiding this comment

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

low langing fruit

not delved in too deep yet, but are the parsing functions (from_one_raw_str etc) still part of -http?

src/types/header.rs Show resolved Hide resolved
src/types/header.rs Show resolved Hide resolved
awc/src/test.rs Outdated Show resolved Hide resolved
@ibraheemdev
Copy link
Member Author

@robjtede I moved the parsing (from_one_raw_str) functions into -web as they were only used once in -http (for ContentEncoding). I can easily change it if you want though.

@robjtede
Copy link
Member

robjtede commented Mar 24, 2021

My thoughts are just that common parsing and formatting functions still belong in -http as long as their inputs or return types are std or HeaderValue or Vec<HeaderValue> etc.

actix-http/Cargo.toml Outdated Show resolved Hide resolved
actix-http/src/header/mod.rs Outdated Show resolved Hide resolved
actix-http/src/header/shared/mod.rs Show resolved Hide resolved
@ibraheemdev
Copy link
Member Author

So which headers from shared should be moved into -web?

@robjtede
Copy link
Member

So which headers from shared should be moved into -web?

i get the impression entity tag is the only one that could move

Copy link
Member

@robjtede robjtede left a comment

Choose a reason for hiding this comment

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

great. i think this is in a state to get merged after CI passes

@robjtede robjtede changed the title implement FromRequest for headers move typed headers and implement FromRequest Apr 1, 2021
@ibraheemdev ibraheemdev added the A-awc project: awc label Apr 1, 2021
@robjtede robjtede merged commit 50dc13f into actix:master Apr 1, 2021
@lovasoa
Copy link

lovasoa commented Apr 1, 2021

Great ! Thank you for implementing this !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-awc project: awc A-http project: actix-http A-web project: actix-web B-semver-major breaking change requiring a major version bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement FromRequest for header types
3 participants