Actix-web: awc 2 does not follow redirects by default, contradicting documentation

Created on 20 Jun 2020  路  6Comments  路  Source: actix/actix-web

Expected Behavior

Documentation describes that HTTP redirects are followed by default.

Current Behavior

Running the example code from docs.rs page for awc outputs HTTP code 301 instead of following the redirect and getting to 200.

Steps to Reproduce (for bugs)

  1. Run the code from the top of the page on https://docs.rs/awc/2.0.0-alpha.2/awc/
  2. Observe 301 code in the output instead of 200

Your Environment

  • Rust Version (I.e, output of rustc -V): rustc 1.44.1 (c7087fe00 2020-06-17)
  • awc: 2.0.0
C-feature P-awc

Most helpful comment

@thiagoarrais Yes, we'd much prefer to actually have the feature. I'd be happy to mentor this feature. I'm considering this issue the tracking issue for the feature.

Feel free to put up a draft PR if you'd like, so we can see what's happening as you make progress. If you have questions I'm active in the Gitter chat.

All 6 comments

I havent the foggiest idea where the builder methods are from for redirects because they do nothing at all and there is no hint of a redirect system anywhere in the client code. Whatsmore, it not possible to support redirections with the existing constructs without breaking changes. Will look into how a larger set of changes would impact the crate.

Needless to say, this is no longer a "good first issue" unless the task is to remove the redirect claims from the docs and deprecate the builder methods.

I have been trying to add redirection with no success (I'm somewhat of a Rust newbie, btw). I'll pause that to work on removing the references to redirect from docs and submit a PR soon.

I'm still willing to add support for redirects, though. I just will need some guidance. Would anyone help me here? I may need some mentoring regarding the borrow checker, futures and all.

@thiagoarrais Yes, we'd much prefer to actually have the feature. I'd be happy to mentor this feature. I'm considering this issue the tracking issue for the feature.

Feel free to put up a draft PR if you'd like, so we can see what's happening as you make progress. If you have questions I'm active in the Gitter chat.

Some notes based research I've done so far:

  • This MDN article is a great reference for the semantics of each redirect type (there are a few and some of them are kinda funky).
  • For security reasons, we should detect cross-origin redirects and omit sensitive headers.
  • If we can, request bodies should be re-used but it's okay to document a known limitation that streamed request bodies are not resent in redirects.

It would be great to have this feature, thank you for the progress guys!

Was this page helpful?
0 / 5 - 0 ratings