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

feat(awc): allow to retrieve request head in client response #3535

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joelwurtz
Copy link
Contributor

PR Type

Feat

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

This pr will allow to add the request head used to send the request to server into the response, this allow by example retrieving the final url in case of a redirect

(This can also be used by other middleware to log a request / response pair also)

Fix #3403

@rharish101
Copy link

I'm getting this error when compiling awc from this branch (as a dependency in another project):

error[E0277]: the trait bound `actix_http::h1::Message<(RequestHeadType, BodySize)>: From<(&mut RequestHeadType, BodySize)>` is not satisfied
  --> /home/rharish/.cargo/git/checkouts/actix-web-aacbeff6ed990534/adf3a06/awc/src/client/h1proto.rs:89:50
   |
89 |         pin_framed.send((&mut head, body.size()).into()).await?;
   |                                                  ^^^^ the trait `From<(&mut RequestHeadType, BodySize)>` is not implemented for `actix_http::h1::Message<(RequestHeadType, BodySize)>`, which is required by `(&mut RequestHeadType, BodySize): Into<_>`
   |
   = help: the trait `From<(RequestHeadType, BodySize)>` is implemented for `actix_http::h1::Message<(RequestHeadType, BodySize)>`
   = help: for that trait implementation, expected `RequestHeadType`, found `&mut RequestHeadType`
   = note: required for `(&mut RequestHeadType, BodySize)` to implement `Into<actix_http::h1::Message<(RequestHeadType, BodySize)>>`

error[E0277]: the trait bound `actix_http::h1::Message<(RequestHeadType, BodySize)>: From<(&mut RequestHeadType, BodySize)>` is not satisfied
  --> /home/rharish/.cargo/git/checkouts/actix-web-aacbeff6ed990534/adf3a06/awc/src/client/h1proto.rs:99:50
   |
99 |         pin_framed.feed((&mut head, body.size()).into()).await?;
   |                                                  ^^^^ the trait `From<(&mut RequestHeadType, BodySize)>` is not implemented for `actix_http::h1::Message<(RequestHeadType, BodySize)>`, which is required by `(&mut RequestHeadType, BodySize): Into<_>`
   |
   = help: the trait `From<(RequestHeadType, BodySize)>` is implemented for `actix_http::h1::Message<(RequestHeadType, BodySize)>`
   = help: for that trait implementation, expected `RequestHeadType`, found `&mut RequestHeadType`
   = note: required for `(&mut RequestHeadType, BodySize)` to implement `Into<actix_http::h1::Message<(RequestHeadType, BodySize)>>`

error[E0277]: the trait bound `actix_http::h1::Message<(RequestHeadType, BodySize)>: From<(&mut RequestHeadType, BodySize)>` is not satisfied
   --> /home/rharish/.cargo/git/checkouts/actix-web-aacbeff6ed990534/adf3a06/awc/src/client/h1proto.rs:147:45
    |
147 |     framed.send((&mut head, BodySize::None).into()).await?;
    |                                             ^^^^ the trait `From<(&mut RequestHeadType, BodySize)>` is not implemented for `actix_http::h1::Message<(RequestHeadType, BodySize)>`, which is required by `(&mut RequestHeadType, BodySize): Into<_>`
    |
    = help: the trait `From<(RequestHeadType, BodySize)>` is implemented for `actix_http::h1::Message<(RequestHeadType, BodySize)>`
    = help: for that trait implementation, expected `RequestHeadType`, found `&mut RequestHeadType`
    = note: required for `(&mut RequestHeadType, BodySize)` to implement `Into<actix_http::h1::Message<(RequestHeadType, BodySize)>>`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `awc` (lib) due to 3 previous errors

@joelwurtz
Copy link
Contributor Author

This is because there was a change in actix-http in order for this to work, you have to use this branch for actix http also

@robjtede robjtede added B-semver-major breaking change requiring a major version bump A-http project: actix-http A-awc project: awc labels Jan 8, 2025
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 B-semver-major breaking change requiring a major version bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

awc: read URL after a redirection
3 participants