jmeter
jmeter copied to clipboard
JMeter does not comply with RFC9110#15.4.8(307 Temporary Redirect)
Expected behavior
When a HTTP server send back a 307 redirection from an original POST method, the user agent need to keep the same method when processing the redirection
Actual behavior
The 307 redirection from a POST request is managed but the method used during the redirection is not a POST anymore. As mentioned in the RFC9110#15.4.8, the redirection is not done according to the rules below:
15.4.8. 307 Temporary Redirect
The 307 (Temporary Redirect) status code indicates that the target resource resides temporarily under a different URI and the user agent MUST NOT change the request method if it performs an automatic redirection to that URI. Since the redirection can change over time, the client ought to continue using the original target URI for future requests. The server SHOULD generate a Location header field in the response containing a URI reference for the different URI. The user agent MAY use the Location field value for automatic redirection. The server's response content usually contains a short hypertext note with a hyperlink to the different URI(s).
Steps to reproduce the problem
Create a HTTP Request sampler targeting a server sending back a 307 redirection.
JMeter Version
5.6
Java Version
openjdk version "11.0.16.1" 2022-08-12 LTS
OS Version
Microsoft Windows [version 10.0.22621.2283]
A proposed patch can be found attached to this thread issue-6080.patch
This looks like a valid bug. @epoitier , do you think you could add a test case as well?
Hi, sorry for the delay in my response. I could add one if we would have an embedded web server to execute the test in this specific case, is there in JMeter any tests which may involve an embedded web server I could use to get some inspiration ?
Check out WireMock-based tests: https://github.com/search?q=repo%3Aapache%2Fjmeter%20wiremock&type=code
For instance:
- https://github.com/apache/jmeter/blob/09c3f810dda7efaf1510ac062454d978d90a0741/src/protocol/http/src/test/kotlin/org/apache/jmeter/protocol/http/sampler/HttpSamplerTest.kt#L81
- https://github.com/apache/jmeter/blob/09c3f810dda7efaf1510ac062454d978d90a0741/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/ParallelResourcesAndIpSource.java#L61
- https://github.com/apache/jmeter/blob/09c3f810dda7efaf1510ac062454d978d90a0741/src/protocol/http/src/test/java/org/apache/jmeter/protocol/http/sampler/TestDecompression.java#L87