Package Details: perl-http-proxy 0.304-1

Git Clone URL: https://aur.archlinux.org/perl-http-proxy.git (read-only, click to copy)
Package Base: perl-http-proxy
Description: HTTP proxy
Upstream URL: http://search.cpan.org/dist/HTTP-Proxy
Licenses: GPL, PerlArtistic
Submitter: sputnick
Maintainer: None
Last Packager: sputnick
Votes: 3
Popularity: 0.000000
First Submitted: 2010-04-03 23:11
Last Updated: 2017-05-25 10:09

Latest Comments

1 2 Next › Last »

YELLOW commented on 2020-07-21 13:07

Extend @neowinx PKGBUILD. Using local patches:

HTTP-Proxy-0.304-Support-IPv6.patch:

From 63bc39b1f29fba4fea22e51fa4b2b64792748740 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Thu, 16 Feb 2017 14:37:26 +0100
Subject: [PATCH] Support IPv6
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When HTTP::Daemon will support IPv6
<https://rt.cpan.org/Public/Bug/Display.html?id=91699>, tests will
fail because LWP::UserAgent still refuses proxy URL with IPv6
numerical host name <https://rt.cpan.org/Public/Bug/Display.html?id=94654>.

Once the LWP::UserAgent is fixed, HTTP-Proxy tests will still fail
because they do not expect a client or server could use IPv6.

This patch fixes the tests and replaces all IO::Socket::INET
occurences with IO::Socket::IP.

Signed-off-by: Petr Písař <ppisar@redhat.com>
---
 lib/HTTP/Proxy.pm |  3 ++-
 t/23connect.t     |  4 ++--
 t/50hopbyhop.t    |  2 +-
 t/50standard.t    | 18 +++++++++++-------
 t/Utils.pm        | 10 +++++-----
 5 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/lib/HTTP/Proxy.pm b/lib/HTTP/Proxy.pm
index a234874..87dccf2 100644
--- a/lib/HTTP/Proxy.pm
+++ b/lib/HTTP/Proxy.pm
@@ -6,6 +6,7 @@ use LWP::UserAgent;
 use LWP::ConnCache;
 use Fcntl ':flock';         # import LOCK_* constants
 use IO::Select;
+use IO::Socket::IP ();
 use Sys::Hostname;          # hostname()
 use Socket qw( SOL_SOCKET SO_SNDBUF SO_RCVBUF );
 use Carp;
@@ -591,7 +592,7 @@ sub _handle_CONNECT {
         $upstream = $response->{client_socket};
     }
     else {                                  # direct connection
-        $upstream = IO::Socket::INET->new( PeerAddr => $req->uri->host_port );
+        $upstream = IO::Socket::IP->new( PeerAddr => $req->uri->host_port );
     }

     # no upstream socket obtained
diff --git a/t/23connect.t b/t/23connect.t
index d1b5ff2..e123203 100644
--- a/t/23connect.t
+++ b/t/23connect.t
@@ -3,7 +3,7 @@ use strict;
 use t::Utils;
 use HTTP::Proxy;
 use LWP::UserAgent;
-use IO::Socket::INET;
+use IO::Socket::IP;

 plan skip_all => "This test fails on MSWin32. HTTP::Proxy is usable on Win32 with maxchild => 0"
   if $^O eq 'MSWin32';
@@ -23,7 +23,7 @@ my $host;
 my $banner = "President_of_Earth Barbarella Professor_Ping Stomoxys Dildano\n";
 {

-    my $server = IO::Socket::INET->new( Listen => 1 );
+    my $server = IO::Socket::IP->new( Listen => 1 );
     plan 'skip_all', "Couldn't create local server" if !defined $server;

     $host = 'localhost:' . $server->sockport;
diff --git a/t/50hopbyhop.t b/t/50hopbyhop.t
index 62943af..8adca04 100644
--- a/t/50hopbyhop.t
+++ b/t/50hopbyhop.t
@@ -13,7 +13,7 @@ $filter->proxy($proxy);
 {
     package MockSocket;
     use vars qw( @ISA );
-    @ISA = qw( IO::Socket::INET );
+    @ISA = qw( IO::Socket::IP );
     # needed by HTTP::Proxy::HeaderFilter::standard
     sub peerhost { "1.2.3.4"; }
 }
diff --git a/t/50standard.t b/t/50standard.t
index 0592cdb..3a391f1 100644
--- a/t/50standard.t
+++ b/t/50standard.t
@@ -47,7 +47,11 @@ if ( $pid == 0 ) {
             SKIP: {
                 skip 'FreeBSD jail does not treat localhost as 127.0.0.1', 1
                     if ($^O eq 'freebsd' && `sysctl -n security.jail.jailed` == 1);
-                is( $req->header("X-Forwarded-For"), '127.0.0.1',
+                # This assumes a client comes from localhost. Ideal test
+                # would check against a value smuggled from the client
+                # in the HTTP request.
+                like( $req->header("X-Forwarded-For"),
+                    qr/^(?:127\.0\.0\.1|::1)$/,
                     "The daemon got X-Forwarded-For" );
             }
             return $res;
@@ -105,19 +109,19 @@ like( $server[0], qr!HTTP::Proxy/\d+\.\d+!, "Correct server name for direct prox

 # we cannot use a LWP user-agent to check
 # that the LWP Client-* headers are removed
-use IO::Socket::INET;
+use IO::Socket::IP ();
+use URI ();

 # connect directly to the proxy
-$proxy->url() =~ /:(\d+)/;
-my $sock = IO::Socket::INET->new(
-    PeerAddr => 'localhost',
-    PeerPort => $1,
+my $sock = IO::Socket::IP->new(
+    PeerAddr => URI->new($proxy->url)->host,
+    PeerPort => URI->new($proxy->url)->port,
     Proto    => 'tcp'
   ) or diag "Can't connect to the proxy";

 # send the request
 my $url = $server->url;
-$url =~ m!http://([^:]*)!;
+$url =~ m!http://([^/]*)!;
 print $sock "GET $url HTTP/1.0\015\012Host: $1\015\012\015\012";  

 # fetch and count the Client-* response headers
diff --git a/t/Utils.pm b/t/Utils.pm
index 9fb44b5..c4005a1 100644
--- a/t/Utils.pm
+++ b/t/Utils.pm
@@ -2,7 +2,8 @@ package t::Utils;

 use strict;
 use Exporter ();
-use IO::Socket::INET;
+use IO::Socket::IP;
+use URI ();
 use vars qw( @ISA @EXPORT @EXPORT_OK );

 @ISA       = qw( Exporter );
@@ -93,10 +94,9 @@ sub bare_request {
     my ($url, $headers, $proxy) = @_;

     # connect directly to the proxy
-    $proxy->url() =~ /:(\d+)/;
-    my $sock = IO::Socket::INET->new(
-        PeerAddr => 'localhost',
-        PeerPort => $1,
+    my $sock = IO::Socket::IP->new(
+        PeerAddr => URI->new($proxy->url)->host,
+        PeerPort => URI->new($proxy->url)->port,
         Proto    => 'tcp'
       ) or do { warn "Can't connect to the proxy"; return ""; };

-- 
2.7.4

HTTP-Proxy-0.304-Fix-Empty-Read.patch:

--- a/t/23connect.t 2020-07-21 15:36:38.746426350 +0300
+++ b/t/23connect.t 2020-07-21 15:37:45.506002189 +0300
@@ -72,7 +72,11 @@
     eval {
         local $SIG{ALRM} = sub { die 'timeout' };
         alarm 30;
-        $read = <$sock>;
+        if ($sock->can('my_read')) {
+            $sock->my_read($read, 1024);
+        } else {
+            $read = <$sock>;
+        }
     };

     ok( $read, "Read some data from the socket" );

PKGBUILD:

# Maintener: sputnick <gilles DOT quenot AT gmail DOT com>
# Generator  : CPANPLUS::Dist::Arch 0.18
pkgname='perl-http-proxy'
pkgver='0.304'
pkgrel='1'
pkgdesc="HTTP proxy"
arch=('i686' 'x86_64')
license=('PerlArtistic' 'GPL')
makedepends=('perl-libwww' 'perl-test-simple')
url='http://search.cpan.org/dist/HTTP-Proxy'
source=("http://mirror.ibcp.fr/pub/CPAN/authors/id/B/BO/BOOK/HTTP-Proxy-${pkgver}.tar.gz" "HTTP-Proxy-0.304-Support-IPv6.patch" "HTTP-Proxy-0.304-Fix-Empty-Read.patch")
md5sums=('09ac64c5f67b7d8baff4ea135d74af48'
         'd5f81bdb0fd2e24f0861718af8e8d20b'
         '759d8a9bebb220a85426e46a9b34a79e')
_dist_dir="HTTP-Proxy-${pkgver}"

prepare() {
  cd "$_dist_dir"
  # Fix bug #120275. https://rt.cpan.org/Public/Bug/Display.html?id=120275
  patch -Np1 -i "${srcdir}/HTTP-Proxy-0.304-Support-IPv6.patch"
  # Fix bug. http://www.cpantesters.org/cpan/report/b7d0a086-d278-11e5-a2ee-9fa967b6c32e
  # https://github.com/book/HTTP-Proxy/issues/7
  patch -Np1 -i "${srcdir}/HTTP-Proxy-0.304-Fix-Empty-Read.patch"
}

build() {
  export PERL_MM_USE_DEFAULT=1 export PERL_AUTOINSTALL=--skipdeps
  { cd "$_dist_dir" &&
    /usr/bin/perl Makefile.PL INSTALLDIRS=vendor &&
    make &&
    make test
  } || return 1
}

package() {
    cd "$_dist_dir"
    find "$pkgdir" -name .packlist -o -name perllocal.pod -delete
    make DESTDIR="$pkgdir" install
}

rimeno commented on 2020-06-18 09:46

Even with the path (with the PKGBUILD proposed by @neowinx), it doesn't compile.

neowinx commented on 2020-02-03 15:40

As @rdoursenaud pointed out, the PKGBUILD needs to contain the patched version or the build doesn't work:

PKGBUILD:

# Maintener: sputnick <gilles DOT quenot AT gmail DOT com>
# Generator  : CPANPLUS::Dist::Arch 0.18
pkgname='perl-http-proxy'
pkgver='0.304'
pkgrel='1'
pkgdesc="HTTP proxy"
arch=('i686' 'x86_64')
license=('PerlArtistic' 'GPL')
makedepends=('perl-libwww' 'perl-test-simple')
url='http://search.cpan.org/dist/HTTP-Proxy'
source=("http://mirror.ibcp.fr/pub/CPAN/authors/id/B/BO/BOOK/HTTP-Proxy-${pkgver}.tar.gz" "https://rt.cpan.org/Public/Ticket/Attachment/1705481/916222/HTTP-Proxy-0.304-Support-IPv6.patch")
md5sums=('09ac64c5f67b7d8baff4ea135d74af48'
         'f1289730e04721c7184ad17fc1c938d9')
_dist_dir="HTTP-Proxy-${pkgver}"

prepare() {
  cd "$srcdir/${_dist_dir}"
  patch --forward --strip=1 --input="${srcdir}/HTTP-Proxy-0.304-Support-IPv6.patch"
}

build() {
  export PERL_MM_USE_DEFAULT=1 export PERL_AUTOINSTALL=--skipdeps
  { cd "$_dist_dir" &&
    /usr/bin/perl Makefile.PL INSTALLDIRS=vendor &&
    make &&
    make test
  } || return 1
}

package() {
    cd "$_dist_dir"
    find "$pkgdir" -name .packlist -o -name perllocal.pod -delete
    make DESTDIR="$pkgdir" install
}

rdoursenaud commented on 2019-05-22 12:42

The relevant patch has been posted there: https://rt.cpan.org/Public/Bug/Display.html?id=120275

It's the same that is applied by Debian.

Please add it to the package.

Thanks.

andreagi commented on 2019-03-03 09:37

There is an issue on the dependency https://www.archlinux.org/packages/extra/any/perl-libwww/ that prevents this package to successfully complete the test where the proxy is an IPv6 address. There are two different issues open on the libwww-perl tracker, see:

https://github.com/libwww-perl/libwww-perl/issues/148

https://github.com/libwww-perl/libwww-perl/issues/237

both the patches correct the file:

/usr/share/perl5/vendor_perl/LWP/UserAgent.pm

this line:

Carp::croak("Bad http proxy specification '$url'") if $url =~ /^https?:/ && $url !~ m,^https?://\w,;

with either:

Carp::croak("Bad http proxy specification '$url'") if $url =~ /^https?:/ && $url !~ m,^https?://(\w|[),;

or

Carp::croak("Bad http proxy specification '$url'") if $url =~ /^https?:/ && $url !~ m,^https?://[\w[],;

alessiotomelleri commented on 2018-09-24 08:54

Hi,

problem still there...

t/20dummy.t ............... Bad http proxy specification .... line 80

@jcorthoefer if your patch works, could you upload it or simply show it ?!

thx in advance to everyone could help here. Alessio

sputnick commented on 2018-04-02 16:27

Latest commit b8065e8 on 16 Jun 2015 https://github.com/book/HTTP-Proxy

sputnick commented on 2018-04-02 16:25

If test fails, it's an upstream issue, not related to aur

astroty commented on 2018-04-02 14:44

Test 20dummy.t is still failing with the error:

t/20dummy.t ............... Bad http proxy specification 'http://[::1]:33485/' at t/20dummy.t line 80.

jcorthoefer commented on 2018-01-19 16:23

This package does not currently build nor do the tests work. I've added patches to at least let it build. I'll submit the diff file as soon as I figure out how to upload it.