-
Notifications
You must be signed in to change notification settings - Fork 62
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
VertxHttpClientHTTPConduit
redirects the request body twice when the body was passed through a single buffer
#1630
Comments
@dcheng1248 thanks for the report! It would be great to have a minimal reproducer. From what you posted, the only difference against our tests (that are passing) I can see is the basic auth. But as you say, it works when you remove the body condition, so the auth headers seem to get redirected properly... |
VertxHttpClientHTTPConduit
gets 404 when communicating with a redirecting endpointVertxHttpClientHTTPConduit
redirects the request body twice when the body was passed through a single buffer
…body was passed through a single buffer, fix quarkiverse#1630
Thanks for the reproducer, @dcheng1248! The issue was that the body was cached twice if there was just a single buffer used to pass the original body. See the fix in #1631 . It is actually strange that our CXF test service happily ignored the second XML document in the request body. I had to adapt the test to run against a plain dummy vert.x endpoint to be able to reproduce it. |
…body was passed through a single buffer, fix quarkiverse#1630
The service rejects the request with two XML root elements only if |
…body was passed through a single buffer, fix #1630
@ppalaga many thanks for the explanations and the quick fix. You guys do awesome work for the community. Looking forward to trying out the fix! |
@ppalaga a colleague tested the fix today on our system and got a |
Yeah, there is no Quarkus property for that, but starting the app with -Dhttp.redirect.max.same.uri.count=42 should do what you need. Adding a new Quarkus property is doable - feel free to file a new issue for that. The bottom line is that when implementing the redirects, I wondered a lot in which situations would multiple hits of a single URI in the redirection chain make any sense. Could you please explain? Is it perhaps some sort of load ballancer that redirects to itself multiple times until it is able to get a free worker node? |
@ppalaga thanks for the information! I created a new issue #1639 for that. Regarding your question, honestly I'm not 100% sure. In our case this is towards a system we don't manage - I wasn't even aware redirection was occurring until I got that 302 Error on quarkus 3.16. That said, I can think of two possible use cases in general.
|
Hm... now when thinking bout the above, where you mention Session management, I wonder whether the lack of auth retransmits (a.k.a. #1616 ) is not what you are really missing? |
In our use case probably not. Auth retransmit deals with 401 or 407, while we get a redirection loop error (not a auth redirection loop) that stems from the same url according to the stack trace. Since the apache implementation also doesn't seems to deal with session cookie headers from 302 (from my quick scan of the source, please correct if I'm wrong), I doubt that's the issue. I would more guess in our case it's either an LB port/server routing through IPHashing etc. or a LB resource management that causes the redirection to the same URL. |
Originally posted in #1609 (comment) by @dcheng1248
I just did a test and unfortunately there still seems to be an issue at the unit test level. I'm actually not sure if this is related to the request data caching vs offloading you mentioned, so any advice would be appreciated. Our request body is very small FWIW, < 10 lines of XML. If my issue is not related to the cache vs offloading, I think this reflects different behaviours of the two HTTP Conduits.
I will give the information I can but need to redact/change some things.
Unit test mocks:
Tests done:
quarkus 3.15, 3.16 and 3.17 with URLConnectionHTTPConduit and VertxHTTPConduit
Results:
3.15:
I only tested the default URLConectionHTTPConduit here. Test passes as expected.
3.16:
The default VertxHTTP fails with a 302 Error as expected.
The URLConnectionHTTP passes as expected.
3.17:
The URLConnectionHTTP passes.
The VertxHTTP fails with a 404 Error. Stack trace:
Upon further investigation, removal of .withRequestBody(matchingXPath(...)) in the stub of RequestFinal() made the test pass. So it seems like it did redirect the request, but the body is not included in the redirected request? I tried to look through the source code but could not find the reason quickly.
PS: One tiny bug I did notice is that in VertxHttpClientHTTPConduit.redirectRetransmit, both the URLs in the debug log refer to the redirection URL (in the previous method the new URL is already added to the list, so list.size()-1 is the new URL, not the old one).
PPS: If it's not too difficult to implement, being able to switch on logging the redirection responses and requests might also help with debugging.
Thanks a lot for your help again.
The text was updated successfully, but these errors were encountered: