Problem
The Target.getPort() method currently returns the raw field value (default -1), which causes invalid URLs when concatenated directly in methods like ShadowingInterceptor.buildTargetUrl(). This produces URLs like http://example.com:-1/path.
Proposed Solution
Modify getPort() to return sensible defaults:
- Return 443 when
sslParser != null (HTTPS)
- Return 80 otherwise (HTTP)
- Return the stored port value when it's explicitly set (> 0)
This ensures valid URLs while maintaining backward compatibility for code that checks if the port is unset.
Context
Problem
The
Target.getPort()method currently returns the raw field value (default -1), which causes invalid URLs when concatenated directly in methods likeShadowingInterceptor.buildTargetUrl(). This produces URLs likehttp://example.com:-1/path.Proposed Solution
Modify
getPort()to return sensible defaults:sslParser != null(HTTPS)This ensures valid URLs while maintaining backward compatibility for code that checks if the port is unset.
Context
core/src/main/java/com/predic8/membrane/core/proxies/Target.java