We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › https requests trough proxy server
Page Index Toggle Pages: 1
https requests trough proxy server (Read 1587 times)
https requests trough proxy server
Apr 16th, 2010, 1:20am
 
Hi evry1,

I'm currently playing with some web services, and have a bunch of questions :

- Is it possible to send GET/POST HTTP/HTTPS requests using core (+provided library) processing ?

- If yes, any simple example ?

- If no, what would be another option? (go for pure java, find a library around that does all the job and wrap it with processing?).

I made research on discourse, looked at processing hacks but could not find a presice answer to my problem.

Thanks lot by advance,
Regards,
O.
Re: https requests
Reply #1 - Apr 16th, 2010, 2:00am
 
1) Yes, see the standard Network library.
2) Lot on the forum, eg. to access Twitter, Google services, to upload a file, and so on.

I see you made searches, perhaps you should provide a simple explanation of what you try to do so we can provide a precise example.
Re: https requests
Reply #2 - Apr 16th, 2010, 2:23am
 
Thx for the quick answer !

I try to implement one of the google authentification api within processing: Either OAuth or ClientLogin – from scratch. ClientLogin seems simpler for a start, so i choosed this one.

I know that google already provide java client library that i could import to simplify the hard work.

Making it from scrath simply help me to understand how does that work as it for learning purpose.

So i'd like to send the HTTP requests from processing and handle XML received from google's servers.

I tried with the standard Network library to connect to google but got that error :

java.net.UnknownHostException: www.google.com
     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
     at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
     at java.net.Socket.connect(Socket.java:525)
     at java.net.Socket.connect(Socket.java:475)
     at java.net.Socket.<init>(Socket.java:372)
     at java.net.Socket.<init>(Socket.java:186)
     at processing.net.Client.<init>(Unknown Source)
     at GoogleTest.setup(GoogleTest.java:64)
     at processing.core.PApplet.handleDraw(Unknown Source)
     at processing.core.PApplet.run(Unknown Source)


I'm at work so behind a proxy server, but i used Properties class to set up the http server and i can load images from the internet with success.

Is tried to connect using port 80 and 443 without success.
The line dropping the error is :

Code:

c = new Client(this,"www.google.com",80);

Hope that help to understand my problem.
Regards.


Re: https requests
Reply #3 - Apr 16th, 2010, 7:17am
 
For what it is worth, there is a thread on parsing google search results. It uses loadStrings but it might have relevant information, perhaps for later.

The code given by timm works for me, although I get a 302 response (redirect).
Re: https requests
Reply #4 - Apr 19th, 2010, 5:27am
 
Many thanks for the help provided PhiLho,

I tried my code at home and it does work !

So the main problem i'm facing now, is calling the google API behind a proxy server.

How can i fetch a remote ressource behing a proxy ?

I've used System.setProperty method to set the http proxy and it does work.

But i do suppose that client use a network socket that's why the host name isn't resolved.

Does someone have any idea ? (even if needs some java code).

Regards,
O.
Re: https requests trough proxy server
Reply #5 - May 16th, 2010, 1:33am
 
@PhiLho:
when getting an 302 google didn't accept your host adress. Usually it helps if you send your IP, so that google can store it;)
e.g: client.write("Host: 192.168.168.168\n\n");
Page Index Toggle Pages: 1