THY02K
May 9th, 2009, 10:40 PM
hello
how do you setup a Http Proxy?
The reason I'm asking is, I'm trying to use a AJAX/Javascript drag drop component from http://script.aculo.us/
It makes call to for example localhost ShoppingCart.aspx using XMLHttpRequest. Now, while it's good with IE to fetch from say:
var url = 'http://localhost:3323/ASPNET_SERVICE/ShoppingCart.aspx';
For firefox, security prevents this. The get around is therefore:
var url = '/proxy?url=' + encodeURIComponent('http://localhost:3323/ASPNET_SERVICE/Default.aspx');
Now to do this first I need to setup a HttpProxy - but I have never done this before.
I browse around a bit and decided to try Privoxy. It's running now and I've configured both Firefox and IE to use proxy 127.0.0.1 8118 per instruction from http://www.privoxy.org/user-manual/quickstart.html. For IE I also make sure "By-pass proxy server for local addresses" is UN-checked. I then point my browser to say www.msn.com - seems like whether browser always able to retrieve page whether I started (or stopped) the proxy. I expect if I stopped the proxy with IE setting configured to use it, I'd have connection problem of some sort ...
And also in AJAX request shouldn't there be a parameter where you NEED to specify proxy enable/disable and proxy port? Using Prototype (http://www.prototypejs.org/api/ajax/options)
var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showResponse} );
(Example from: http://www.ajaxlessons.com/2006/02/19/ajax-workshop-3-shopping-cart-using-scriptaculous/)
Or using vanilla Javascript:
var url="gethint.asp";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
The biggest problem I have now is that if I use "/proxy" in my HttpRequest url - i.e.
var url = '/proxy?url=' + encodeURIComponent('http://localhost/JavascriptAJAXTest/Default.aspx');
// Instead of: var url = 'http://localhost:3323/ASPNET_SERVICE/Default.aspx';
then I get "HTTP 404 - File not found" - I checked the resource it's definitely there.
http://localhost/JavascriptAJAXTest/Default.aspx
I pointed browser at this, this is fine (no query string please note)
http://localhost/JavascriptAJAXTest/Default.aspx
When I pointed browser at this (with query string) then it says page cannot be found?
http://localhost/JavascriptAJAXTest/Default.aspx&product_id=product_3&rand=0.6798043816565259
I checked IIS Log:
05:29:15 127.0.0.1 - W3SVC1 LAPPC2 127.0.0.1 80 GET /proxy url=http%3A%2F%2Flocalhost%2FJavascriptAJAXTest%2FDefault.aspx?product_id=product_2&rand=0.5694375981715101 404 2 4184 606 16 HTTP/1.0 localhost Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+3.0.04506.648;+.NET+CLR+3.5.21022;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.4506.2152;+.NET+CLR+3.5.30729) - http://localhost/Javascript/script.aculo.us/scriptaculous-js-1.8.2/SimpleDragDropTest.html
I then pointed my browser at:
http://localhost/JavascriptAJAXTest/Default.aspx?product_id=product_2&rand=0.5694375981715101
The page is certainly there.
Thanks
REF:
http://www.prototypejs.org/api/ajax/request
http://www.xml.com/pub/a/2005/11/09/fixing-ajax-xmlhttprequest-considered-harmful.html
Privoxy
Download: http://sourceforge.net/project/showfiles.php?group_id=11118
User Manual: http://www.privoxy.org/user-manual/index.html
General: http://www.privoxy.org/
how do you setup a Http Proxy?
The reason I'm asking is, I'm trying to use a AJAX/Javascript drag drop component from http://script.aculo.us/
It makes call to for example localhost ShoppingCart.aspx using XMLHttpRequest. Now, while it's good with IE to fetch from say:
var url = 'http://localhost:3323/ASPNET_SERVICE/ShoppingCart.aspx';
For firefox, security prevents this. The get around is therefore:
var url = '/proxy?url=' + encodeURIComponent('http://localhost:3323/ASPNET_SERVICE/Default.aspx');
Now to do this first I need to setup a HttpProxy - but I have never done this before.
I browse around a bit and decided to try Privoxy. It's running now and I've configured both Firefox and IE to use proxy 127.0.0.1 8118 per instruction from http://www.privoxy.org/user-manual/quickstart.html. For IE I also make sure "By-pass proxy server for local addresses" is UN-checked. I then point my browser to say www.msn.com - seems like whether browser always able to retrieve page whether I started (or stopped) the proxy. I expect if I stopped the proxy with IE setting configured to use it, I'd have connection problem of some sort ...
And also in AJAX request shouldn't there be a parameter where you NEED to specify proxy enable/disable and proxy port? Using Prototype (http://www.prototypejs.org/api/ajax/options)
var myAjax = new Ajax.Request( url, {method: 'get', parameters: pars, onLoading: showLoad, onComplete: showResponse} );
(Example from: http://www.ajaxlessons.com/2006/02/19/ajax-workshop-3-shopping-cart-using-scriptaculous/)
Or using vanilla Javascript:
var url="gethint.asp";
url=url+"?q="+str;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
The biggest problem I have now is that if I use "/proxy" in my HttpRequest url - i.e.
var url = '/proxy?url=' + encodeURIComponent('http://localhost/JavascriptAJAXTest/Default.aspx');
// Instead of: var url = 'http://localhost:3323/ASPNET_SERVICE/Default.aspx';
then I get "HTTP 404 - File not found" - I checked the resource it's definitely there.
http://localhost/JavascriptAJAXTest/Default.aspx
I pointed browser at this, this is fine (no query string please note)
http://localhost/JavascriptAJAXTest/Default.aspx
When I pointed browser at this (with query string) then it says page cannot be found?
http://localhost/JavascriptAJAXTest/Default.aspx&product_id=product_3&rand=0.6798043816565259
I checked IIS Log:
05:29:15 127.0.0.1 - W3SVC1 LAPPC2 127.0.0.1 80 GET /proxy url=http%3A%2F%2Flocalhost%2FJavascriptAJAXTest%2FDefault.aspx?product_id=product_2&rand=0.5694375981715101 404 2 4184 606 16 HTTP/1.0 localhost Mozilla/4.0+(compatible;+MSIE+6.0;+Windows+NT+5.1;+SV1;+.NET+CLR+3.0.04506.648;+.NET+CLR+3.5.21022;+.NET+CLR+2.0.50727;+.NET+CLR+3.0.4506.2152;+.NET+CLR+3.5.30729) - http://localhost/Javascript/script.aculo.us/scriptaculous-js-1.8.2/SimpleDragDropTest.html
I then pointed my browser at:
http://localhost/JavascriptAJAXTest/Default.aspx?product_id=product_2&rand=0.5694375981715101
The page is certainly there.
Thanks
REF:
http://www.prototypejs.org/api/ajax/request
http://www.xml.com/pub/a/2005/11/09/fixing-ajax-xmlhttprequest-considered-harmful.html
Privoxy
Download: http://sourceforge.net/project/showfiles.php?group_id=11118
User Manual: http://www.privoxy.org/user-manual/index.html
General: http://www.privoxy.org/