pk1986 / recaptcha4j

Automatically exported from code.google.com/p/recaptcha4j
0 stars 0 forks source link

How to set proxy host and port to validate recaptcha4j #8

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Followed the steps of implementation in this project home page.

What is the expected output? What do you see instead?
 Recaptcha response object has failed and the message is recaptcha not reachable.

What version of the product are you using? On what operating system?
I am using 0.0.8 version on Windows XP.

Please provide any additional information below.

Upon research i found that i need to set the proxy host and proxy port to the 
URL instance that is being created in SimpeHttpLoader. I need a way to pass 
these values to recaptcha api.

Original issue reported on code.google.com by vallam.k...@gmail.com on 9 Jun 2011 at 4:44

GoogleCodeExporter commented 9 years ago
Seconded.

However, it looks like you can subclass simplehttploader as a workaround and 
use ReCaptchaImpl.setHttpLoader.

Original comment by luke.bid...@gmail.com on 3 Aug 2011 at 4:09

GoogleCodeExporter commented 9 years ago
Hi,
Try this :
reCaptcha.setHttpLoader(new 
SimpleProxyHttpLoader(proxyHost,Integer.parseInt(proxyPort)));
        }

Original comment by d.bo...@gmail.com on 2 Nov 2011 at 1:37

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
It will be easier to sub-class with the following change to SimpleHttpLoader 

Original comment by ishai...@gmail.com on 27 Oct 2012 at 1:25

Attachments:

GoogleCodeExporter commented 9 years ago
Proxy settings can be controlled with system properties as described here 
http://docs.oracle.com/javase/6/docs/technotes/guides/net/proxies.html. 

Original comment by ishai...@gmail.com on 27 Oct 2012 at 1:50

GoogleCodeExporter commented 9 years ago
We needed this (we need the proxy just for recaptcha, for the other urls we 
don't need it). I just created a class SimpleProxyHttpLoader as suggested by  
d.bo...@gmail.com , with almost the same code as SimpleHttpLoader, with the 
following modifications:

Create a proxy:
SocketAddress addr = new InetSocketAddress(this.proxyHost, this.proxyPort);
proxy = new Proxy(Proxy.Type.HTTP, addr);

When opening the connection:
connection = url.openConnection(proxy);

Original comment by rafael.s...@gmail.com on 2 May 2013 at 3:33

GoogleCodeExporter commented 9 years ago
Have you consider add the source of SimpleProxyHttpLoader to the project?

Original comment by lucas.bo...@gmail.com on 10 Oct 2013 at 2:42

Attachments: