olt / corsa

CORS proxy and web server for static apps
MIT License
6 stars 6 forks source link

Proxy requests with url containing %20 return 400 Bad Request #1

Open stylpe opened 10 years ago

stylpe commented 10 years ago

I'm using corsa to proxy a Jenkins server. We have jobs with spaces in the name.

When I try the following: curl 'http://localhost:8888/proxy/http://jenkins:8080/job/Test%20Job/api/json?pretty=true' -D -

I get:

HTTP/1.1 400 Bad Request
Date: Wed, 20 Aug 2014 14:37:04 GMT
Content-Length: 0
Content-Type: text/html; charset=UTF-8
Access-Control-Allow-Origin: *
Server: Jetty(8.y.z-SNAPSHOT)

Other jobs (without space in the name) work fine.

stylpe commented 10 years ago

And I just figured out why. Tornado has percent-decoded the path that is passed to request_handler, and it is not re-percent-encoded before being used in the HTTPRequest. I was able to work around it by escaping my request url: curl 'http://localhost:8888/proxy/http://jenkins:8080/job/Test%2520Job/api/json?pretty=true' -D -