clusterfk / chaos-proxy

ClusterFk Chaos Proxy is an unreliable HTTP proxy you can rely on; a lightweight tool designed for chaos testing of microservices.
http://clusterfk.it
GNU General Public License v3.0
97 stars 11 forks source link

Bug/3 encoding curly brackets #4

Closed ShaneLee closed 4 months ago

ShaneLee commented 4 years ago

Thought I'd have a look at this issue (#3 )

The fix in this pull request means that calls with encoded curly brackets now returns a 404 not found error and doesn't crash the system with a 500 error.

Haven't incremented the version number in the POM as it looks like it's staying at '0.0.1-SNAPSHOT', but happy to change if required.

piomar123 commented 4 years ago

I am still getting incorrect request URI with this solution. The problem is that targetUrl is not completely encoded, some characters are decoded by the servlet.getServletPath() method and are passed decoded into the server. (For example Unicode characters.) It causes the target server to fail.

I found a solution - targetUrl should be encoded which can be achieved by replacing servlet.getServletPath() with servlet.getRequestURI() in ProxyTargetUrlBuilder class (instead of the change in this PR):

return new URL(chaosProxyConfigurationService.getDestinationServiceHostProtocolAndPort() + request.getRequestURI());

EDIT: How I tested: started a Python server python3 -m http.server 8080 in a folder with files containing Unicode chars in name, configured it as ChaosProxy destination and tried to download these files.