LukeMathWalker / wiremock-rs

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

Redirect on POST form submission raises Hyper IncompleteBody error #72

Closed guspower closed 3 years ago

guspower commented 3 years ago

Hi,

I'm trying to mock a service that performs a redirect on POST when given x-www-form-urlencoded form data. I'm using a ureq Agent instance to submit the form. What I observe is that the request library runs until timeout; I have created a cut-down example that replicates the problem I'm seeing.

I'm unsure whether this error is caused by my stupidity, a ureq bug, a wiremock bug or something else.

Any and all help gratefully received.

EDIT: I've added a warp standalone server into the example that provides the same redirect-on-post functionality and have verified that the ureq client usage works with it.

guspower commented 3 years ago

Update: It turns out that it's caused by a bug in ureq, specifically that it sends the Content-Length header on the subsequent GET request after the POST is redirected. This tricks hyper into thinking there is content available and it fails on trying to retrieve it with an UnexpectedEof.

LukeMathWalker commented 3 years ago

Sorry we couldn't help, but thanks for updating with your findings - it might be useful to others!

guspower commented 3 years ago

No worries - I've opened a PR against ureq which will hopefully fix the issue.