Skip Menu |

This queue is for tickets about the libwww-perl CPAN distribution.

Report information
The Basics
Id: 40912
Status: resolved
Priority: 0/
Queue: libwww-perl

People
Owner: Nobody in particular
Requestors: dave [...] dtsp.co.nz
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 5.820
Fixed in: (no value)



Subject: There is no clean interface allowing binding a specific UserAgent to a specific local IP address
There is no clean interface allowing binding a specific UserAgent to a specific local IP address. There isn't really a dirty way to do it either! You can go: @LWP::Protocol::http::EXTRA_SOCK_OPTS = (LocalAddr => $bindAddress); ... but astute readers will have already noted that this is a global setting, and so not greatly helpful if you want to use different local addresses under different circumstances. Could an interface please be added to support setting the local address on a per-UserAgent basis?
+1 for this request. If the module maintainer agrees, I can provide a patch.
On Wed Apr 29 10:29:18 2009, AAR wrote: Show quoted text
> +1 for this request. > > If the module maintainer agrees, I can provide a patch.
I would like to see this capability as well. So what's your plan for an interface for this? It's probably a good idea to agree on that first.
On Wed Apr 29 10:29:18 2009, AAR wrote: Show quoted text
> +1 for this request. > > If the module maintainer agrees, I can provide a patch.
I would like to see this capability as well. So what's your plan for an interface for this? It's probably a good idea to agree on that first.
From: dave [...] dtsp.co.nz
On Wed Apr 29 12:22:16 2009, GAAS wrote: Show quoted text
> I would like to see this capability as well. So what's your plan for > an interface for this? It's > probably a good idea to agree on that first.
I would be happy with, say, LWP::UserAgent::local_address($addr), which would set the LocalAddr value as per IO::Socket::INET. The UserAgent seems a sensible place to set it. The most obvious approach is to do it identically to how LWP::UserAgent::timeout() passes through to IO::Socket::INET via LWP::Protocol::request(). That would involve adding Yet Another parameter to LWP::Protocol::request(). Actually, a simpler approach might be to do it like the connection cache. For that, LWP::Protocol::http just pulls it out of its LWP::UserAgent reference. That avoids changing the LWP::Protocol::request() API.
By googling i found an old patch dated 2000 at http://markmail.org/message/gthvd5yjzofdv233?q=LWP::UserAgent+set+address&page=1&refer=gthvd5yjzofdv233 For sure this patch doesn't work anymore, but the way it would work seems fine to me. Torsten
On Sun Oct 11 19:57:02 2009, torsten@archesoft.de wrote: Show quoted text
> By googling i found an old patch dated 2000 at >
http://markmail.org/message/gthvd5yjzofdv233?q=LWP::UserAgent+set+address&page=1&refer=gthvd5yjzofdv233 Show quoted text
> > For sure this patch doesn't work anymore, but the way it would work > seems fine to me.
It looks ok to me. I'm happy to update and test this patch against my own use cases if it's essentially acceptable for pulling into the distribution?
The 'local_address' attribute of LWP::UserAgent has now been implemented in <http://github.com/gisle/libwww- perl/commit/28387e346169a427f578858635624618695443d1>. I would really have liked to find some solution that worked for other parameters that you might want to pass to the socket object as well, but all those interface suggestions that I came up with was worse in many ways. Other relevant options are IO::Socket::INET's MultiHomed, the Net::HTTP options SendTE, MaxLineLength, MaxHeaderLines and various Net::FTP options like Firewall and Passive. I'll get to that some other day.