Package Details: perl-http-proxy 0.304-2

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: zeppelinlg
Votes: 3
Popularity: 0.000000
First Submitted: 2010-04-03 23:11 (UTC)
Last Updated: 2022-06-27 11:02 (UTC)

Latest Comments

1 2 Next › Last »

B3l3tte commented on 2022-10-29 16:47 (UTC)

This patch is working as intended :

--- a/t/90httpstatus.t  2015-06-16 02:47:39.000000000 +0200
+++ b/t/90httpstatus.t  2022-10-29 18:33:50.926602276 +0200
@@ -9,7 +9,7 @@
     @url = (
         map ( [ "$_" => 0 + $_ ], 200 .. 206, 300, 304, 306 ),
         map ( [ "$_" => 0 + $_, 200 ], 301 .. 303, 305, 307 ),
-        map ( [ "$_" => 0 + $_ ], 400 .. 418, 500 .. 505 ),
+        map ( [ "$_" => 0 + $_ ], 400 .. 418, 500 .. 503, 505 ),
     );
     $tests += @$_ - 1 for @url;
 }

If you want to unite it with the existing HTTP-Proxy-0.304-Fix-Test.patch which already modifies this file, here it is :

--- a/t/90httpstatus.t  2015-06-16 02:47:39.000000000 +0200
+++ b/t/90httpstatus.t  2022-10-29 18:46:24.135909100 +0200
@@ -9,7 +9,7 @@
     @url = (
         map ( [ "$_" => 0 + $_ ], 200 .. 206, 300, 304, 306 ),
         map ( [ "$_" => 0 + $_, 200 ], 301 .. 303, 305, 307 ),
-        map ( [ "$_" => 0 + $_ ], 400 .. 418, 500 .. 505 ),
+        map ( [ "$_" => 0 + $_ ], 400 .. 418, 500 .. 503, 505 ),
     );
     $tests += @$_ - 1 for @url;
 }
@@ -19,7 +19,7 @@
 use HTTP::Request::Common;
 use t::Utils;

-my $base = 'http://httpstat.us';
+my $base = 'https://httpstat.us';

 plan tests => $tests;

@@ -36,7 +36,7 @@
     $proxy->init;

     my $ua = LWP::UserAgent->new( keep_alive => 1 );
-    $ua->proxy( http => $proxy->url );
+    $ua->proxy( https => $proxy->url );

     # fork the proxy
     my $pid = fork_proxy($proxy);

B3l3tte commented on 2022-10-29 16:31 (UTC)

The 504 error is not due to upstream but to the test backend : https://github.com/aaronpowell/httpstatus/issues/89#issuecomment-705978272 I think we need to skip the 504 test or hit another URL proposing the same kind of service.

I'll try to write a patch and post it here.

B3l3tte commented on 2022-08-16 15:19 (UTC)

Hello, I have the same error as @MarsSeed during the test phase :

#   Failed test '504 => 504 OK'
#   at t/90httpstatus.t line 48.
#          got: '200'
#     expected: '504'
# Looks like you failed 1 test of 45.

MarsSeed commented on 2022-06-27 11:27 (UTC) (edited on 2022-06-27 11:27 (UTC) by MarsSeed)

Please move the make test command to a separate check() function.

Currently that test execution also freezes for a long time and then errors out, thereby preventing the build phase to finish and the package cannot be created.

PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
# 
# Versions for all modules listed in MYMETA.json (including optional ones):
# 
# === Configure Requires ===
# 
#     Module              Want Have
#     ------------------- ---- ----
#     ExtUtils::MakeMaker  any 7.64
# 
# === Build Requires ===
# 
#     Module              Want Have
#     ------------------- ---- ----
#     ExtUtils::MakeMaker  any 7.64
# 
# === Test Requires ===
# 
#     Module                Want     Have
#     --------------------- ---- --------
#     ExtUtils::MakeMaker    any     7.64
#     File::Find             any     1.40
#     File::Spec             any     3.84
#     File::Spec::Functions  any     3.84
#     HTML::Parser             3     3.78
#     HTTP::Headers          any     6.36
#     HTTP::Request          any     6.36
#     HTTP::Request::Common  any     6.36
#     IO::Socket::INET       any     1.49
#     Test::More             any 1.302190
#     base                   any     2.27
#     warnings               any     1.58
# 
# === Test Recommends ===
# 
#     Module         Want     Have
#     ---------- -------- --------
#     CPAN::Meta 2.120900 2.150010
# 
# === Runtime Requires ===
# 
#     Module              Want   Have
#     ------------------- ---- ------
#     Carp                 any   1.52
#     Exporter             any   5.77
#     Fcntl                any   1.15
#     File::Path           any   2.18
#     File::Spec           any   3.84
#     File::Temp           any 0.2311
#     HTTP::Daemon         any   6.14
#     HTTP::Date           any   6.05
#     HTTP::Headers::Util  any   6.36
#     IO::Handle           any   1.48
#     IO::Select           any   1.49
#     LWP::ConnCache       any   6.60
#     LWP::UserAgent       any   6.60
#     POSIX                any   2.03
#     Socket               any  2.033
#     Sys::Hostname        any   1.24
#     constant             any   1.33
#     strict               any   1.12
#     vars                 any   1.05
# 
t/00-report-prereqs.t ..... ok
t/00basic.t ............... ok
t/05new.t ................. ok
t/10init.t ................ ok
t/11log.t ................. ok
maxconn is deprecated, please use max_connections at t/15accessors.t line 47.
maxserve is deprecated, please use max_keep_alive_requests at t/15accessors.t line 47.
t/15accessors.t ........... ok
t/15deprecated.t .......... ok
t/16stash.t ............... ok
t/17fstack.t .............. ok
t/18engine.t .............. ok
t/20dummy.t ............... ok
t/20keepalive.t ........... ok
t/22http.t ................ ok
t/22transparent.t ......... ok
# socket is non blocking, switching to blocking mode
t/23connect.t ............. ok
t/23https.t ............... skipped: Can't make this work with Crypt::SSLeay
t/40push_filters.t ........ ok
t/41filters.t ............. ok
t/42will_modify.t ......... ok
t/50hopbyhop.t ............ ok
t/50standard.t ............ ok
t/50via.t ................. ok
t/51simple.t .............. ok
t/51simple2.t ............. ok
t/61simple.t .............. ok
t/61simple2.t ............. ok
t/64htmltext.t ............ ok
t/64lines.t ............... ok
t/64tags.t ................ ok
t/66htmlparser.t .......... ok
t/67complete.t ............ ok
t/67save.t ................ ok
t/71rot13.t ............... ok

#   Failed test '504 => 504 OK'
#   at t/90httpstatus.t line 48.
#          got: '200'
#     expected: '504'
# Looks like you failed 1 test of 45.
t/90httpstatus.t .......... 
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/45 subtests 
t/release-distmeta.t ...... skipped: these tests are for release candidate testing
t/release-pod-coverage.t .. skipped: these tests are for release candidate testing
t/release-pod-syntax.t .... skipped: these tests are for release candidate testing

Test Summary Report
-------------------
t/90httpstatus.t        (Wstat: 256 (exited 1) Tests: 45 Failed: 1)
Failed test:  44
Non-zero exit status: 1
Files=37, Tests=465, 158 wallclock secs ( 0.13 usr  0.04 sys +  4.83 cusr  0.78 csys =  5.78 CPU)
Result: FAIL
Failed 1/37 test programs. 1/465 subtests failed.
make: *** [Makefile:977: test_dynamic] Error 255
==> ERROR: A failure occurred in build().

YELLOW commented on 2020-07-21 13:07 (UTC)

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 (UTC)

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

neowinx commented on 2020-02-03 15:40 (UTC)

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 (UTC)

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 (UTC) (edited on 2019-03-03 09:43 (UTC) by andreagi)

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 (UTC)

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