Actix-web: Dropping scheme and authority from URI for ServiceRequest passed into middleware

Created on 13 Aug 2019  路  2Comments  路  Source: actix/actix-web

When calling req.uri() from inside some middleware service the scheme and authority seems to be dropped from the ServiceRequest.

This code here checks for authority and scheme and throws an error if they're missing.
https://github.com/hlb8122/keyserver-rust/blob/8394043e801c090ff56e5048d69f39e8569c12ab/src/net/payments.rs#L253

Initializing a testing app like this:
https://github.com/hlb8122/keyserver-rust/blob/8394043e801c090ff56e5048d69f39e8569c12ab/src/net/payments.rs#L451
passes the the check above.

However initializing the app like this:
https://github.com/hlb8122/keyserver-rust/blob/8394043e801c090ff56e5048d69f39e8569c12ab/src/main.rs#L78
fails the check above?

I'm unsure whether the the authority and scheme are being dropped because
a) It's within the scope
b) It's a release app rather than a test app

Any ideas?

Most helpful comment

http1.1 does not pass scheme and authority with request, usually it is something like GET /index.html
to generate right urls you have to use connection info

All 2 comments

http1.1 does not pass scheme and authority with request, usually it is something like GET /index.html
to generate right urls you have to use connection info

Thank you kindly.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zhaobingss picture zhaobingss  路  4Comments

yoshrc picture yoshrc  路  5Comments

naturallymitchell picture naturallymitchell  路  4Comments

uncotion picture uncotion  路  3Comments

joshsleeper picture joshsleeper  路  3Comments