How Do I Use Proxy in Net:HTTP?

Can anyone tell me how the proxy is implemented in LWP:UserAgent? I have to
use a proxy in Net:HTTP, but proxy is not supported in it.


0
ir (3)
10/15/2003 6:26:03 PM
comp.lang.perl.misc 33003 articles. 0 followers. brian (1246) is leader. Post Follow

6 Replies
899 Views

Similar Articles

[PageSpeed] 40
On Wed, 15 Oct 2003 18:26:03 GMT, "Public Interest" <ir@labranche.com>
wrote:

>Can anyone tell me how the proxy is implemented in LWP:UserAgent? 
>I have to use a proxy in Net:HTTP, but proxy is not supported in it.

$ua->proxy(['http'] => "http://$proxy:$port");
0
Helgi
10/15/2003 7:07:43 PM
"Public Interest" <ir@labranche.com> writes:

> Can anyone tell me how the proxy is implemented in LWP:UserAgent? I have to
> use a proxy in Net:HTTP, but proxy is not supported in it.

Net::HTTP support proxies just fine.  RFC 2616 explains how to do it.
You basically just provide full absolute URLs with the requests you
send.

-- 
Gisle Aas
0
gisle
10/15/2003 10:22:10 PM
Please give me a line or two showing how to use proxy..

In UserAgent it is:
$ua->proxy(['http', 'ftp'], 'http://proxy.sn.no:8001/');

Can do use the same line in Net:Http? I don' know how use use 2616.

<gisle@activestate.com> ????
news:m3ad82rvjh.fsf@eik.i-did-not-set--mail-host-address--so-shoot-me...
> "Public Interest" <ir@labranche.com> writes:
>
> > Can anyone tell me how the proxy is implemented in LWP:UserAgent? I have
to
> > use a proxy in Net:HTTP, but proxy is not supported in it.
>
> Net::HTTP support proxies just fine.  RFC 2616 explains how to do it.
> You basically just provide full absolute URLs with the requests you
> send.
>
> -- 
> Gisle Aas


0
Public
10/19/2003 4:51:53 AM
Public Interest wrote:

>Please give me a line or two showing how to use proxy..
>
>In UserAgent it is:
>$ua->proxy(['http', 'ftp'], 'http://proxy.sn.no:8001/');
>
>Can do use the same line in Net:Http? I don' know how use use 2616.

No. As Gisle Aas wrote, you have to do a low level connection yourself.
Thank goodness, the difference between a direct connection and a
connection via proxy is minimal. The gist is:

For a normal connection, you 
 - connect to  a host/port, and 
 - request for a URL that looks like an absolute Unix path. (= relative
to the domain root)

For a proxy connection, you
 - connect to the proxy, and
 - request for an absolute URL, including protocol ("http"), domain and
optionally, port.

Here's an example modified from the Synopsis of Net::Http, which
requests a page on a port different from the default for http, 80:

	use Net::HTTP;
	my $s = Net::HTTP->new(Host => "modperl.com", PeerPort => 9000)
 	  or die $@;
	$s->write_request(GET => "/perl_networking/errata.html");
	my($code, $mess, %h) = $s->read_response_headers;

	print "Response code: $code ($mess)\n";
	use Data::Dumper;
	print Data::Dumper->Dump([\%h], ['*headers']);
	print "\n";

	{
	    my $n = $s->read_entity_body(my $buf, 1024);
	    die "read failed: $!" unless defined $n;
	    print $buf;
	    redo if $n;
	}

Here is it again, for another URL, and modified to connect via the proxy
of my ISP (<http://proxy.pandora.be:8080>):

	use Net::HTTP;
	my $s = Net::HTTP->new(Host => "httpd.apache.org",
	  PeerAddr => 'proxy.pandora.be', PeerPort => 8080) or die $@;
	$s->write_request(GET =>
	  "http://httpd.apache.org/docs/misc/FAQ.html");
	my($code, $mess, %h) = $s->read_response_headers;

	print "Response code: $code ($mess)\n";
	use Data::Dumper;
	print Data::Dumper->Dump([\%h], ['*headers']);
	print "\n";

	{
	    my $n = $s->read_entity_body(my $buf, 1024);
	    die "read failed: $!" unless defined $n;
	    print $buf;
	    redo if $n;
	}

IMO the code to retrieve data via a proxy is actually simpler than for a
normal connection, because (almost) everything but the URL for the GET
is constant.

n.b. I think the Host property is mainly important if you encounter name
based virtual hosts, otherwise you could get pages from the wrong
domain.

-- 
	Bart.
0
Bart
10/19/2003 11:42:41 AM
Dear Master Bart,

Thank YOU.
My own code was:
 my $s = Net::HTTP->new(Host => '64.161.246.100:8080') || die $@;
 $s->write_request(GET => 'http://quote.yahoo.com', 'User-Agent' =>
'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)' );

So I did not know the syntax of using proxy, because it was not said in it.

My final question on this: Why do I have to put host here? Because I put
peeradd which is proxy server, peerport and the abs url. Your said the Host
is important for virtual domain, but you already has the full url to let
httpd to know? Can I do?

> my $s = Net::HTTP->new(
>   PeerAddr => 'proxy.pandora.be', PeerPort => 8080) or die $@;
> $s->write_request(GET =>
>   "http://httpd.apache.org/docs/misc/FAQ.html");

or

> my $s = Net::HTTP->new(Host => "httpd.apache.org",
>   PeerAddr => 'proxy.pandora.be', PeerPort => 8080) or die $@;
> $s->write_request(GET =>
>   "/docs/misc/FAQ.html");


..


0
Public
10/20/2003 6:25:13 AM
One of things I don't undertand is you and I both read the same document on
Net::Http, there is no such info as what I need, but you can write a correct
code and I could not. Do you have a better documation file or a better cook
book? What you explained to me on how to use the proxy is no where found.
Don't know how you first guessed the syntax right.


0
Public
10/20/2003 6:54:13 AM
Reply:
Similar Artilces:

Use of cluster
Hi I am not familar with the use of cluster,. See my attahed in verion 7.1 How am I going to manipulate the contols or indicators, I supposed only property node can work, isn't it? &nbsp; Clement cluster1.vi: http://forums.ni.com/attachments/ni/170/177767/1/cluster1.vi If you want to change the values of the cluster elements on the front panel, then you can either write to the Value property of the cluster (or the Value property of the individual cluster elements), write to a local variable of the cluster, or write to the indicator terminal (in the case of a cluster indicator).&...

Having Trouble with File I/O (win32 API) -- Using NASM and ALINK
I'm not sure what I am doing wrong. I run the exe, and a file is not created. I'm still trying to figure out how to debug this thing in windows. I assembled the below code with: nasm -f obj createfile.asm alink -oPE -subsys con createfile.obj Here's my source code: import CreateFileA kernel32.dll import ExitProcess kernel32.dll import CloseHandle kernel32.dll import WriteFile kernel32.dll extern CreateFileA extern ExitProcess extern CloseHandle extern WriteFile %include "win32n.inc" ; downloaded at rs1.szif.hu/~tomcat/win32 -- contains definitions for win32 par...

Question about using split
All I have a string which I want to split on the characters "SA", simple enough, I also want to (in the same expression) split on "sa" just to catch any lowercase characters, however I would like the characters SA/sa to remain in the array after the split, it's simple enough to append it back on, but it is a little clumsy and has caused some problems. Can anyone suggest a solution? PT In article <binuh4$bf0j0$1@ID-116287.news.uni-berlin.de>, Max Adams <rubberducky703@hotmail.com> wrote: : All I have a string which I want to split on the characters ...

updated "Using Python From IDL" ebook
All, I just added a chapter to the ebook on creating tones from IDL using a Pyth= on package called pyaudio. I also found a free plugin for Visual Studio th= at gives you a good IDE for python. (http://pytools.codeplex.com/) This not only gives a nice DE it also allows us to do interactive debugging= with Python from IDL. Of course, I explain it all in the book which can b= e purchased here (http://www.rlkling.com/using-python-from-idl.htm) for $5.= 00 US. If you have already purchased the book you are supposed to get free= updates. Thanks! Ronn Kling On Wednesday, Jul...

When to use Tcl_DecrRefCount() and when not to?
I am using SWIG to interface a C library (libgpgme) that uses callbacks to Tcl and have written some C code to implement Tcl coded callbacks. The SWIG interface code looks like this: %{ /* C Structure containing the Tcl_Interp and the script prefix. */ typedef struct { Tcl_Interp *theinterp; Tcl_Obj *thecommand; } tcl_callback_hook; /* Actual C callback, that evals a Tcl script made from the stored script prefix, with the callback parameters uid_hint, passphrase_info, and prev_was_bad lappended. The result of this evaluation is written to the file descr...

How to find free disk space using C
Hi, I am trying to incorporate a code snippet which would calculate the free disk space of any drive passed to it as argument but presently stuck with it. Can anyone help me out with sample code? I have already tried with the follwoing: typedef BOOL (WINAPI *P_GDFSE)(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER); void main (int argc, char **argv) { BOOL fResult; char *pszDrive = NULL, szDrive[4]; DWORD dwSectPerClust, dwBytesPerSect, dwFreeClusters, dwTotalClusters; ...

using coherence function
Hi All, I'm having some trouble understanding how to use the "mscohere" command to get my coherence function. I have a bunch of force and corresponding acceleration signals which I have measured at one point in my test structure. I know I have to use the average of all of these in the coherence function. From the "mscohere" command in matlab, I see that the inputs are x and y, which in my case would be force and acc. however this just allows me to look at one measurement, not the average of all the measurements. If I were to just use 1 measurement, the coherence funct...

Need some help with pre-processign functions in C using Doxygen ...
Hi, I'm currently documenting source code in C and would like to skip some functions that don't need to be documented. The syntax that I'm using is defined below. #ifndef SKIP /* Code to be skipped */ #endif SKIP Where SKIP= Predifined Tag Name I'd like to know if anyone on this list has been using Doxygen to pre-process code fragments. In case you do pre-process the code, I'd appreciate your inputs with an alternative method to ignore code fragments. The problem is that Doxygen compiles it but the C compiler reads the /* Code to be skipped */ as comments !!! Plea...

using setTimeout when using prototype
I have an object, and I define the following: var processForm=new Object(); processForm=function(inservleturl) { this.inservleturl = inservleturl; this.submitForm(); } processForm.prototype.submitForm2=function() { } processForm.prototype.submitForm=function() { setTimeout("submitStep2()", 20); } How can the submitForm function's setTimeout call submitStep2? Thank you. processForm=function(inservleturl) { this.inservleturl = inservleturl; this.submitForm(); } processForm.prototype.submitForm2=function() { ...

FAQ 2.13 Perl on the Net: FTP and WWW Access
This message is one of several periodic postings to comp.lang.perl.misc intended to make it easier for perl programmers to find answers to common questions. The core of this message represents an excerpt from the documentation provided with Perl. -------------------------------------------------------------------- 2.13: Perl on the Net: FTP and WWW Access To get the best performance, pick a site from the list at http://www.cpan.org/SITES.html . From there you can find the quickest site for you. You may also use xx.cpan.org where "xx" is the 2-letter country code f...

OT: What filtering does Hotmail use?
This is completely off-topic, but I hope someone here knows the answer.=20 When talking to one of my sisters today I asked about an invitation I = sent her last week to her hotmail.com address. She said that she did not = receive it. One of my other sisters did not respond to the same email and it = turns out that she also uses hotmail.com. Another friend who uses hotmail did = not respond to a recent email as I expected them to. I created my own hotmail account tonight and sent an email to it from my domain more than two hours ago, that email has not yet arrived in my = hotmail account. My ...

Re: Scope of macro variable using "call symput" #12
Perahps the way SAS calculates the scope of a macro variable created by CALL SYMPUT violates the principle of least astonishment. It might make more sense for CALL SYMPUT to create a new macro-level symbol table, rather than searching upwards to find one that already exists. Or maybe not. The SYMPUTX way, which lets you specify the scope, is slightly more work to use but can create results that don't require thought or knowledge of context. On Mon, 24 Mar 2008 09:48:11 -0400, "Chang Chung" <chang_y_chung@HOTMAIL.COM> said: > On Sun, 23 Mar 2008 02:05:16 -0700, Rola...

What Rbls are you using
Hello I would like to know which DNS RBLs everyone is using and what do you find most effective. I just started using dsn.rfc-ignorant.org and list.dsbl.org. So far no complaints. I have also been using bl.spamcop.net and sbl.spamhaus.org for awhile. They're ok however some get through. Thanks, J -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Fri, 13 Jan 2006 20:39:21 -0800, jpecki wrote: > Hello > I would like to know which DNS RBLs everyone is using and what do you > find most effective. I just started using dsn.rfc-ignorant.org and > list.dsbl.org. So far no compl...

Net: netlabs.org newsletter #139
++ From the VOICE OS/2-eCS News Service http://www.os2voice.org ++ From: newsDESPAM@DESPAMnetlabs.org This is the latest edition of the bi-weekly http://netlabs.org newsletter. The newsletter can be read on the web at the following URL: http://wiki.netlabs.org/index.php/Netlabs_bi_weekly_newsletter2 News from http://netlabs.org: 9. May - 15. May ACPI Subsystem for eComStation Two tickets for Dell Vostro 1520 and one fix See: http://svn.netlabs.org/acpi/timeline Dynamic Windows Library Various updates and preparation for 2.0 release See: http://svn.netlabs.org/dwindows/timelin...

voive recognition using matlab
good day, i would like to ask a program/code using MatLab for my project voice recognition for my subject... thank you very much....... ...

Is it possible to use an Object as value for a <html:select> (i'm using struts)
Hi, I'm having trouble with struts, well actually i don't know if the problem is struts or instead i'm assuming html to be capable of something it's not. I have a ValidatorForm, say VF and one of it's attibutes called organismo is an object of type Ob1, Ob1 being a bean definded in another file, Ob1 has just two attributes a and b and their respective setters and getters. I want that attribute to be filled with the value of a <html:select>, depending on what the user chooses from the options available. To get the options i'm using the next: <html:select pro...

using ethereal
I have Fedora Core 3. When I did my install I did not install X windows or any GUI. I also did not install ethereal. Now I would like to use ethereal, so I installed Xwindows and KDE. I used yum install ethereal and it showed it installed it. But I cannot figure out how to run ethereal. I cannot find any binary to run. I found one post that said I should have an ethereal file under /usr/X11R6/bin but I don't. thank you jb Jason Benway wrote: > I have Fedora Core 3. When I did my install I did not install X windows or > any GUI. I also did not install ethereal. >...

Using Oracle 8.1.7 OCI JDBC Driver WIth Oracle 9i Database
Has anyone had any problems using the 8.1.7 OCI JDBC driver with a 9i database? Oracle states they are compatible at the following URL: http://otn.oracle.com/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#_1_ "Matt" <mdavey4@csc.com> wrote in message news:f2892d3a.0307241304.6295d05c@posting.google.com... > Has anyone had any problems using the 8.1.7 OCI JDBC driver with a 9i database? > > Oracle states they are compatible at the following URL: > http://otn.oracle.com/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#_1_ Any reason not to trust that statement? If ...

Using a DLL from a Lotusscript agent
Hello, I have a LotusScript web agent that uses a external DLL. The agent works fine, but I have a performance problem. The DLL has 2 functions: initialize and translate. The first one performs some initialization tasks and the second one translates a word from a language to another. The problem is that the initialization task takes some time and it seems once the script ends, the DLL loses its iniatilization and I have to initialize it again, slowing down the whole process. Is there any way to keep the dll initialized once the "initialize" function is called and the ...

How to get Service Ticket when we have TGT using java.
Hi, We are implementing WS Kerberos authentication using java. We went throught the sample providied @ http://services.iic.ac.in/kbase/docs/java2/guide/security/jgss/tutorials/AcnOnly.html We have setup Fedora Core 3 and krb5-server and configured. When we run the sample code it gets authenticated successfully, but my question is : How to get Kerberos Service Ticket after logging in succesfully and getting the TGT using java 1.4.2_04 and Fedora Core 3 [krb5-server] LoginContext lc ... ... lc.login(); after this step, we can say lc.getSubject() which contains the kerberos ticket, now usin...

How do I start and stop a RedHat Daemon using /etc/aliases (RedHat 9.0 and sendmail 8.10.12)
Hi, the task that I'm trying to do is to start and stop a daemon on a RedHat 9 system by sending mail to that system (using the /etc/aliases file that would use a pipe to a command). But I've been unsuccessful!! I know that I have 2 issues: - permissions (sendmail cannot execute a command that can be executed by root - syntax error in the /etc/aliases file This is what I've tried to put in the /etc/aliases file: the.alias: "|/etc/init.d/daemon start" and the.alias: |/etc/init.d/daemon start This is the error mesage that I get all the time in my local mail log fil...

Re: Who is using my hard disk...?
Have you try the MSinfo.exe or Msinfo32.exe. It comes with Windows 95 and higher. Joseph -----Original Message----- From: Stratosfear [mailto:stratoulis@yahoo.com] Posted At: Friday, September 12, 2003 9:01 AM Posted To: misc Conversation: Who is using my hard disk...? Subject: Who is using my hard disk...? Hello, Is there any way to find out why, once in a while, there is heavy disk activity on my system. that last for an hour or so...? It is very possible that I have setup a scheduled activity, like backup, or virus scan, but I have checked all my installed apps and still do not know w...

migrating shared folder using imapsync from 1 cyrus server to the other
Hello, I posted a similar message a couple of days ago but received no response maybe due to the fact I did not explain what I wanted to do correctly. I would like to migrate a shared folder (not the 'user' folder) using imapsync or another imap utility from one cyrus server to another. Is there a quick way of doing this? TIA ...

Read Text from Webpage Using Matlab
I tried to use the urlread() command to pull information from a website but it kept giving me an error on a particular line number and if it did finish it would result in ' '. Is there a different method or tool to retrieve info from a website? Are there limitations on the websites that will work? Thanks! On Feb 5, 9:57=A0am, "John Thornton" <psueng...@hotmail.com> wrote: > I tried to use the urlread() command to pull information from a website b= ut it kept giving me an error on a particular line number and if it did fin= ish it would result in ' '. =A...

error using gpg....
i'm getting an error when I try to run gpg thru a thin client, this is the command I'm using: cat /home/cdb1/.passphrase |gpg --passphrase-fd 0 --output OUTPUT.TXT --decrypt FILE.PGP > tmp 2>&1 this is the error in tmp: gpg: cannot open /dev/tty: No such address or device I'm using a thin client app called DBC Smart Client, it seems as if this doesn't support the /dev/tty feature, it connects to our Linux server from a windows workstation (DOS prompt) using TCP/IP. Does anyone know a way around this ? thanks in advance.... On Wed, 13 Jul 20...