jmeter icon indicating copy to clipboard operation
jmeter copied to clipboard

Forward slash removed from URL when following redirects

Open farazive opened this issue 2 years ago • 2 comments

Expected behavior

JMeter should be able to follow redirects that contain full URLS as route parameters. For instance, a HTTP 302 such as

Location: https://example.com/host/https://test.com

should make JMeter go to the actual URL "https://example.com/host/https://test.com". JMeter is stripping a slash after /host/https: and ends up following https://example.com/host/https:/test.com. When the backend server at example.com receives the route parameter for host, it gets https:/test.com instead of the expected https://test.com

Actual behavior

jmeter.log file attached: jmeter.log

JTL file attached: test.txt

JMX file attached: testjmx.txt

Steps to reproduce the problem

The Bug

When following redirects which contain https:// in the URL's path like the example below:

https://ela1.s-ela.elmodev.com/oauth2-client/anon/check-authcode/host/https://ela1.elmodev.com/?state={redacted}&code={redacted}

where the path contains the text host/https://ela1.elmodev.com/

JMeter strips a slash after "https:" and the actual call it makes is

2023-10-24 15:46:48,795 DEBUG o.a.h.wire: http-outgoing-3 >> "GET /oauth2-client/anon/check-authcode/host/https:/ela1.elmodev.com/?state={redacted}&code={redacted} HTTP/1.1[\r][\n]"

host/https://ela1.elmodev.com/ is converted into host/https:/ela1.elmodev.com/ which is a malformed URL.

You can see that in the the logs at "ALL" level, collected from GUI below as well:

2023-10-24 15:46:48,793 DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager: Connection [id: 2][route: {s}->https://ela1.elmodev.com:443][state: Login TMS Thread Group 1-1] can be kept alive indefinitely
2023-10-24 15:46:48,793 DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection: http-outgoing-2: set socket timeout to 0
2023-10-24 15:46:48,793 DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager: Connection released: [id: 2][route: {s}->https://ela1.elmodev.com:443][state: Login TMS Thread Group 1-1][total available: 1; route allocated: 1 of 2; total allocated: 1 of 20]
2023-10-24 15:46:48,793 DEBUG o.a.j.p.h.s.HTTPHC4Impl: ResponseHeadersSize=635 Content-Length=5 Total=640
2023-10-24 15:46:48,793 DEBUG o.a.j.p.h.s.HTTPSamplerBase: Initial location: https://ela1.s-ela.elmodev.com/oauth2-client/anon/check-authcode/host/https://ela1.elmodev.com/?state=redacted&code=redacted
2023-10-24 15:46:48,793 DEBUG o.a.j.p.h.s.HTTPSamplerBase: Location after /. and space transforms: https://ela1.s-ela.elmodev.com/oauth2-client/anon/check-authcode/host/https://ela1.elmodev.com/?state=redacted&code=redacted
2023-10-24 15:46:48,793 DEBUG o.a.j.p.h.s.HTTPSamplerBase: Location as URL: https://ela1.s-ela.elmodev.com/oauth2-client/anon/check-authcode/host/https://ela1.elmodev.com/?state=redacted&code=redacted
2023-10-24 15:46:48,793 DEBUG o.a.j.p.h.s.HTTPHC4Impl: Start : sample https://ela1.s-ela.elmodev.com/oauth2-client/anon/check-authcode/host/https://ela1.elmodev.com/?state=redacted&code=redacted method GET followingRedirect true depth 0
2023-10-24 15:46:48,793 DEBUG o.a.j.p.h.s.HTTPHC4Impl: Reusing the HttpClient: @660347056 https://ela1.s-ela.elmodev.com
2023-10-24 15:46:48,793 DEBUG o.a.j.p.h.c.HC4CookieHandler: Found 1 cookies for https://ela1.s-ela.elmodev.com/oauth2-client/anon/check-authcode/host/https://ela1.elmodev.com/?state=redacted&code={redacted}
2023-10-24 15:46:48,794 DEBUG o.a.j.p.h.s.HTTPHC4Impl: Found user token:Login TMS Thread Group 1-1 as JMeter variable:__jmeter.U_T__, storing it in HttpContext
2023-10-24 15:46:48,794 DEBUG o.a.h.c.p.RequestAddCookies: CookieSpec selected: default
2023-10-24 15:46:48,794 DEBUG o.a.h.c.p.RequestAddCookies: Unsupported cookie policy: default
2023-10-24 15:46:48,794 DEBUG o.a.h.c.p.RequestAuthCache: Auth cache not set in the context
2023-10-24 15:46:48,794 DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager: Connection request: [route: {s}->https://ela1.s-ela.elmodev.com:443][state: Login TMS Thread Group 1-1][total available: 1; route allocated: 1 of 2; total allocated: 1 of 20]
2023-10-24 15:46:48,794 DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager: Connection leased: [id: 3][route: {s}->https://ela1.s-ela.elmodev.com:443][state: Login TMS Thread Group 1-1][total available: 0; route allocated: 1 of 2; total allocated: 1 of 20]
2023-10-24 15:46:48,794 DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection: http-outgoing-3: set socket timeout to 0
2023-10-24 15:46:48,794 DEBUG o.a.h.i.e.MainClientExec: Executing request GET /oauth2-client/anon/check-authcode/host/https:/ela1.elmodev.com/?state=redacted&code={redacted} HTTP/1.1
2023-10-24 15:46:48,794 DEBUG o.a.h.i.e.MainClientExec: Target auth state: UNCHALLENGED
2023-10-24 15:46:48,794 DEBUG o.a.h.i.e.MainClientExec: Proxy auth state: UNCHALLENGED
2023-10-24 15:46:48,794 DEBUG o.a.h.headers: http-outgoing-3 >> GET /oauth2-client/anon/check-authcode/host/https:/ela1.elmodev.com/?state=redacted&code=redacted HTTP/1.1
2023-10-24 15:46:48,794 DEBUG o.a.h.headers: http-outgoing-3 >> Connection: keep-alive
2023-10-24 15:46:48,794 DEBUG o.a.h.headers: http-outgoing-3 >> Cookie: PHPSESSID=ebf36fee4874b757a2306915ee4746f7
2023-10-24 15:46:48,794 DEBUG o.a.h.headers: http-outgoing-3 >> Host: ela1.s-ela.elmodev.com
2023-10-24 15:46:48,794 DEBUG o.a.h.headers: http-outgoing-3 >> User-Agent: Apache-HttpClient/4.5.14 (Java/11.0.20.1)
2023-10-24 15:46:48,795 DEBUG o.a.h.wire: http-outgoing-3 >> "GET /oauth2-client/anon/check-authcode/host/https:/ela1.elmodev.com/?state=redacted&code=redacted HTTP/1.1[\r][\n]"

I have attached the JMX, JTL and jmeter.log files below but wasn't able to spot a malformed URL in the file contents but the behavior is the same in both GUI and non-GUI modes.

JMeter Version

5.6.2

Java Version

openjdk version "11.0.20.1" 2023-08-24

OS Version

No response

farazive avatar Oct 24 '23 05:10 farazive

If you are under control of the first URL, can you try to encode the slashes and maybe the doublecolon like .../host/http%3A%2F%2Fela1...

FSchumacher avatar Oct 25 '23 15:10 FSchumacher

Thanks for your response. We don't have control of the URL. However, I worked around the issue by going to the "Advanced" tab of the HTTP Request sampler, and changing the Client implementation from the default "HTTPClient4" to "Java". Even though I am not blocked by this ticket, I'd say the "HTTPClient4" should behave the same as the "Java" implementation.

farazive avatar Oct 31 '23 04:10 farazive