Proxy Server with wxURL Topic is solved
Proxy Server with wxURL
In my application I use wxURL to access the internet and retrieve information from a web page. The problem is, it doesn't work from behind my user's proxy server. How would I go about getting around this? Is it as simple as changing my url from www.wxforum.org to www.wxforum.org:proxyPort ?
Thanks for the help.
Thanks for the help.
-
- Part Of The Furniture
- Posts: 1511
- Joined: Sun Jun 19, 2005 11:37 am
- Location: Singapore
- Contact:
tho im pretty sure your know the difference... SetDefaultPRoxy works globally, SetProxy workson a per-instance basis... just so you know.
For those people wanting to use HTTP low-level, to use a proxy you connect to the proxy instead of the server, and use this:
GET http://server.com/path/to/file.php HTTP/1.1
HOST: server.com
Connection: Close
That is, if my research tells me right...
For those people wanting to use HTTP low-level, to use a proxy you connect to the proxy instead of the server, and use this:
GET http://server.com/path/to/file.php HTTP/1.1
HOST: server.com
Connection: Close
That is, if my research tells me right...
Hmm, even though I think my code is right, something is still awry. Here's what I'm using:
I've been playing with both SetDefaultProxy and SetProxy. When I use SetProxy, data == NULL and the if check fails. When I use SetDefaultProxy data is != NULL but on attempting to read from it the program crashes so I can only assume that it's garbage data. I'm confident that my proxy is working because my browser can tunnel through it to get on the internet (I'm using squid on Fedora Core).
Do you have an actual working example that you've used to connect to a proxy that I can look at, or can you see where I'm going wrong?
Thanks for your help.
Code: Select all
wxInputStream *data;
// wxURL::SetDefaultProxy(proxyStr);
wxURL url2(goTo); // goto is the full url to a php script
url2.SetProxy(proxyStr); //proxy string is in the format proxyServer:port
data = url2.GetInputStream();
if (!data)
ErrorMessage("Connection to proxy failed.");
else {
ErrorMessage("Connection successfull.")
}
Do you have an actual working example that you've used to connect to a proxy that I can look at, or can you see where I'm going wrong?
Thanks for your help.
Sure,
goto = {"http://www.mycustomcd.com/index.php"}
and proxyStr = {"192.168.1.101:80"}
My ip is 192.168.1.102.
-Tyler
goto = {"http://www.mycustomcd.com/index.php"}
and proxyStr = {"192.168.1.101:80"}
My ip is 192.168.1.102.
-Tyler
It was a blasted bug in wx. I believe I've got it.
in src\common\url.cpp I altered the code to be the following:
The fix is above. That gives me a valid stream object, but looks like I'm going to have to make similar fixes elsewhere because the data coming back doesn't look kosher.
in src\common\url.cpp I altered the code to be the following:
Code: Select all
// When we use a proxy, we have to pass the whole URL to it.
wxInputStream *the_i_stream;
if (!m_useProxy)
{
the_i_stream = m_protocol->GetInputStream(m_url);
}
else
{
wxString fullPath = /*Begin Fix*/m_url +/*End Fix*/ m_path;
if (HasQuery())
fullPath += wxT("?") + m_query;
if (HasFragment())
fullPath += wxT("#") + m_fragment;
the_i_stream = m_protocol->GetInputStream(fullPath);
}
if (!the_i_stream)
-
- Earned some good credits
- Posts: 101
- Joined: Wed Jun 29, 2005 10:13 pm
- Location: Portugal
- Contact:
CVS
Could someone confirm that this has been fixed on the CVS ?
I am using 2.6.2, after setting up the proxy the GetInputStream() simply blocks for some time and I don't get a successfull result.
Thanks
I am using 2.6.2, after setting up the proxy the GetInputStream() simply blocks for some time and I don't get a successfull result.
Thanks
wxMSW 2.6.3 - GCC 3.4.2 (MinGW/MSYS)
wxGTK 2.6.3 - GCC 4.02 (Ubuntu)
Code::Blocks Win/Lin
PTlink Tech Admin
PTlink Chat Software Lead Developer
http://software.pt-link.net
wxGTK 2.6.3 - GCC 4.02 (Ubuntu)
Code::Blocks Win/Lin
PTlink Tech Admin
PTlink Chat Software Lead Developer
http://software.pt-link.net
- Ryan Norton
- wxWorld Domination!
- Posts: 1319
- Joined: Mon Aug 30, 2004 6:01 pm
Re: CVS
Are you sure the proxy server works? If you give me a few slices of code I can test here if you'd like.Lamego wrote:Could someone confirm that this has been fixed on the CVS ?
I am using 2.6.2, after setting up the proxy the GetInputStream() simply blocks for some time and I don't get a successfull result.
Thanks
[Mostly retired moderator, still check in to clean up some stuff]
-
- Earned some good credits
- Posts: 101
- Joined: Wed Jun 29, 2005 10:13 pm
- Location: Portugal
- Contact:
test code
I am sure the proxy works, I am using for my daily browsing, also I am using with a wxSocket connection (estbalishing an HTTP tunnel).
The proxy is from an company intranet so you wouldn't be able to use it:
The proxy is from an company intranet so you wouldn't be able to use it:
Code: Select all
// Try to fech online logo
wxURL url(_("http://www.pt-link.net/services/logo.png"));
url.SetProxy(_("proxy.mycompany.com:8080"));
wxInputStream *data = url.GetInputStream();
if(data)
{
wxFile fTest(_("logo.png"), wxFile::write );
wxFileOutputStream streamout( fTest );
data->Read(streamout);
fTest.Close();
}
wxMSW 2.6.3 - GCC 3.4.2 (MinGW/MSYS)
wxGTK 2.6.3 - GCC 4.02 (Ubuntu)
Code::Blocks Win/Lin
PTlink Tech Admin
PTlink Chat Software Lead Developer
http://software.pt-link.net
wxGTK 2.6.3 - GCC 4.02 (Ubuntu)
Code::Blocks Win/Lin
PTlink Tech Admin
PTlink Chat Software Lead Developer
http://software.pt-link.net
-
- Earned some good credits
- Posts: 101
- Joined: Wed Jun 29, 2005 10:13 pm
- Location: Portugal
- Contact:
strange
It did work with a squid proxy setup on localhost, I need to do some investigation. It would be some problem specicif to the proxy version I am using.
wxMSW 2.6.3 - GCC 3.4.2 (MinGW/MSYS)
wxGTK 2.6.3 - GCC 4.02 (Ubuntu)
Code::Blocks Win/Lin
PTlink Tech Admin
PTlink Chat Software Lead Developer
http://software.pt-link.net
wxGTK 2.6.3 - GCC 4.02 (Ubuntu)
Code::Blocks Win/Lin
PTlink Tech Admin
PTlink Chat Software Lead Developer
http://software.pt-link.net