1. http_get behind a proxy

Hello everybody,

I'm trying to retrive a web page using http_get:

url = "http://www.google.com" 
txt_url = http_get(url) 
 
if atom(txt_url) or length(txt_url) = 0 then 
   error = 1 
end if 

but when I use this at work, I'm behind a proxy server and I get an error.

How can I solve this?

Thanks,

papinic

new topic     » topic index » view message » categorize

2. Re: http_get behind a proxy

I found

[proc] 
 
set_http_proxy_mode ( atom http, atom on ) 

in wxEuphoria. Can it help me?

new topic     » goto parent     » topic index » view message » categorize

3. Re: http_get behind a proxy

up

new topic     » goto parent     » topic index » view message » categorize

4. Re: http_get behind a proxy

http_get does not have proxy support as of now, sorry.

Jeremy

new topic     » goto parent     » topic index » view message » categorize

5. Re: http_get behind a proxy

Ok, so I tried with wget. The code I am using is:

system("wget -q -O " & "temp.html \"" &  url & "\"", 0) 
return {0, read_file("temp.html")} 

but each call to wget makes a black console screen flash. Is there any way to avoid the black screen?

Also I noticed that http_get (also without proxy) causes my application to stop, without any evidence in ex.err. I am using euphoria 4.0.3.

Thanks.

Papinic

new topic     » goto parent     » topic index » view message » categorize

6. Re: http_get behind a proxy


What is the address of your proxy and the port number?

useless

new topic     » goto parent     » topic index » view message » categorize

7. Re: http_get behind a proxy


Write a .bat file such as:

set http_proxy=http://ip-number:port-number/ 
c:\wget\wget.exe -k --connect-timeout=60 -nc -PE:\asubdir\ -oE:\log-this4.txt -w60 -Dsomedomain.com  -x --user-agent="Mozilla/3.0" -e robots=off http://somedomain.com/path/filename.html 
then do something like

sleep(1) 
junk = system_exec(YourBatFileName,2) 

then read the file into your program.

useless

new topic     » goto parent     » topic index » view message » categorize

8. Re: http_get behind a proxy

Thanks, it works.

But, is there a way to avoid the black screen and to execute the command in background?

new topic     » goto parent     » topic index » view message » categorize

9. Re: http_get behind a proxy

Does anyone understand the internals of how http proxies work that could modify the code to allow http proxy support directly in Euphoria?

Jeremy

new topic     » goto parent     » topic index » view message » categorize

10. Re: http_get behind a proxy

Euphoria's socket library is based on my eunet project. The eunet_get_http function accepted 3 arguments: IP address, hostname, and file name. Normally, the IP address is the resolved address of hostname; but in the case of a proxy, it would the the IP address:port of the proxy. I don't know if the socket library still has enough of the eunet internals to support this.

new topic     » goto parent     » topic index » view message » categorize

11. Re: http_get behind a proxy

m_sabal said...

Euphoria's socket library is based on my eunet project. The eunet_get_http function accepted 3 arguments: IP address, hostname, and file name. Normally, the IP address is the resolved address of hostname; but in the case of a proxy, it would the the IP address:port of the proxy. I don't know if the socket library still has enough of the eunet internals to support this.

OK. So if I understand this right the only thing we would need to do is provide a 3rd option to http_get that is an address of a proxy server and then connect to that IP address (if supplied) and then just pass on the normal GET request? That sounds easy enough, is that the case? I'll code it up and have it ready for 4.1.

Jeremy

new topic     » goto parent     » topic index » view message » categorize

12. Re: http_get behind a proxy

papinic said...

Hello everybody,

I'm trying to retrive a web page using http_get:

url = "http://www.google.com" 
txt_url = http_get(url) 
 
if atom(txt_url) or length(txt_url) = 0 then 
   error = 1 
end if 

but when I use this at work, I'm behind a proxy server and I get an error.

How can I solve this?

Thanks,

papinic

Can you backup your existing EUDIR/include/net/http.e and replace it with http://scm.openeuphoria.org/hg/euphoria/file/eac268f96290/include/std/net/http.e ? Then use the new method: set_proxy_server(ip, port) and let me know how that works out?

Jeremy

new topic     » goto parent     » topic index » view message » categorize

13. Re: http_get behind a proxy

Hi Jeremy,

thank you for your interest in this problem. On Monday I'll be back to work and I'll check your solution.

Papinic

new topic     » goto parent     » topic index » view message » categorize

14. Re: http_get behind a proxy

papinic said...

thank you for your interest in this problem. On Monday I'll be back to work and I'll check your solution.

Thanks!

Jeremy

new topic     » goto parent     » topic index » view message » categorize

15. Re: http_get behind a proxy

m_sabal said...

Euphoria's socket library is based on my eunet project. I don't know if the socket library still has enough of the eunet internals to support this.

Although true at one point in time, I'm pretty sure this is no longer the case, considering that most of the socket library is written in C and additionally that Jeremy rewrote all or most of http.e

new topic     » goto parent     » topic index » view message » categorize

16. Re: http_get behind a proxy

No way...

I think the problem is that the proxy needs authentication... is there a way to pass username and password?

new topic     » goto parent     » topic index » view message » categorize

17. Re: http_get behind a proxy

papinic said...

No way...

I think the problem is that the proxy needs authentication... is there a way to pass username and password?

My tests with the new library method works with anonymous proxies. I am not sure how to interact with an authenticating proxy. I'll have to do some research.

Jeremy

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu