LukeMathWalker / wiremock-rs

HTTP mocking to test Rust applications.
Apache License 2.0
617 stars 70 forks source link

request: Fix URI conversion when authority part is present #73

Closed Tuetuopay closed 3 years ago

Tuetuopay commented 3 years ago

This fixes a panic that happened when the incoming request sets the full path with authority (e.g. when using Tonic). The then-formatted URI was incorrect, leading to ParseErrors, which turned into panics.

Testing for the port is enough to determine whether the incoming request has the authority part set, however it does not uses it correctly: it formats the URI to parse as "http://localhost:{port}{uri}" which is incorrect, since uri already contains localhost:{port}, resulting in completely bogus URIs like http://localhost:33593http://localhost:33593/grpc.examples.echo/UnaryEcho.

This completely removes the formatting in case the authority is present, and simply stringifies the incoming URI.