• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HttpClient Apache Commons Client and remove encoding the url's

 
steve labar
Ranch Hand
Posts: 55
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please can someone help me! I'm using the appache commons client and am very pleased. However, the specific use I have i need to make sure that the url's are not encoded so that when i make the request and get back a response from the server the inputs in the url were not encoded and thus are as they were in response.

I have done this

method.setURI(new URI(url, false)); // where false is supposeto not encode the url.

However i think it is still encoding when i execute?

any ideas why?
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see a two-argument constructor in java.net.URI. Does this code compile?
 
steve labar
Ranch Hand
Posts: 55
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, it does compile. It is a class in the apache commons library. Have you ever used this library before? i'm pretty new to it. But don't understand why it is encoding my urls
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's always a good idea to mention the fully-qualified name of a class, just in case of name collision: Tell The Details.
As for your problem, the documentation for org.apache.commons.httpclient.URI says:

public URI(String s, boolean escaped)
. . .
escaped - true if URI character sequence is in escaped form. false otherwise.


I would take that to mean that if you set escaped to false, the class will encode the URI, as it mentions elsewhere:
A URI is always in an "escaped" form, since escaping or unescaping a completed URI might change its semantics.



 
steve labar
Ranch Hand
Posts: 55
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for the response however this is still an issue. When you set it to true it expects you "the client" to have it properly formatted. When it is false you just give it the url and it encodes it for you.

I need to connect with the url not encoded at all. I do vulnerability testing and i need the request/response to be untouched. Just as if a proxy made the request.

any ideas?
 
Paul Clapham
Sheriff
Pie
Posts: 20203
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay. So don't encode the URL, but tell the constructor that it is encoded. Then (most likely, I'm guessing here) the constructor will not attempt to encode your input.
 
steve labar
Ranch Hand
Posts: 55
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that sounds reasonable tried that while ago and got.

org.apache.commons.httpclient.URIException: Invalid query
at org.apache.commons.httpclient.URI.parseUriReference(URI.java:2049)
at org.apache.commons.httpclient.URI.<init>(URI.java:147)
at org.apache.commons.httpclient.HttpMethodBase.getURI(HttpMethodBase.java:265)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:383)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
 
Joe Ess
Bartender
Posts: 9214
9
Linux Mac OS X Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It sounds like the class is doing some error checking to keep you honest.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic