Forward slash removed from URL when following redirects
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.3k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 5
Description
### 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](https://github.com/apache/jmeter/files/13110715/jmeter.log)
JTL file attached: [test.txt](https://github.com/apache/jmeter/files/13110724/test.txt)
JMX file attached: [testjmx.txt](https://github.com/apache/jmeter/files/13110729/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_
Contributor guide
Assessment
This issue has not been assessed yet.