libwww-perl / libwww-perl/Net-HTTP

can_read issue with Net::SSL [rt.cpan.org #98898]

Open
#61 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Perl
Stars
20
Forks
27
PR merge metrics
No merged PRs in 30d

Description

Migrated from rt.cpan.org#98898 (status was 'open')

Requestors:

  • hv@crypt.org

From hv@crypt.org on 2014-09-15 13:09:32
:

My $work app has encountered a problem that I believe is identical to
rt#81237, but with Net::SSL rather than IO::Socket::SSL as the underlying
socket library.

Our current plan to address this is to upgrade to latest Crypt::SSLeay
(which exposed the 'pending' method in a recent change) and then apply
the following local patch (against Net-HTTP-6.06, but should apply over
6.07 as well):

--- lib/perl5/Net/HTTP/Methods.pm.old   2013-03-10 22:35:43.000000000 +0000
+++ lib/perl5/Net/HTTP/Methods.pm   2014-09-15 14:05:38.000000000 +0100
@@ -284,6 +284,7 @@
     my $self = shift;
     return 1 unless defined(fileno($self));
     return 1 if $self->isa('IO::Socket::SSL') && $self->pending;
+    return 1 if $self->isa('Net::SSL') && $self->pending;

     # With no timeout, wait forever.  An explict timeout of 0 can be
     # used to just check if the socket is readable without waiting.

It looks like the support for pending() came in between 0.65_02 and 0.65_04
of Crypt::SSLeay, so it isn't obvious how Net::HTTP should incorporate
a similar fix - if you're using an older Crypt::SSLeay you'll get something
like:
  Can't locate object method "pending" via package "LWP::Protocol::https::Socket" at lib/perl5/Net/HTTP/Methods.pm line 287.

Hugo


From http://xlogon.net/amock on 2014-10-15 12:48:54
:

Hi all,

I'm pretty sure that I was just hit by this bug too. 
I'm using LWP to make HTTP POST requests to a site. 

The following combination works fast as expected:

Net::HTTP 6.01
Crypt::SSLeay 0.57
IO::Socket::INET 1.31

The follwoing combination does return after a long period (timeout):
Net::HTTP 6.06 also 6.07
Crypt::SSLeay 0.57
IO::Socket::INET 1.31

I found the same portion of code with profiling the weired test run with Devel::NYTProf showing that the call to can_read spent most of the time.

Following the proposed patch I installed newest Crypt::SSLeay and Net::HTTP, added the line and the measured runtime is as expected.

I'm writing this because I'm pretty sure that this bug happens in the wild and is a kind of backward compatibility regression of Net::HTTP.
Important is that the method 'pending' of 'Net::SSL' is introduced in one of the younger versions. The right dependencies must be set.

Regards
McA


From http://xlogon.net/amock on 2014-10-15 14:34:21
:

As an addendum:
I did some research on that to find a solution to my problem. It seems that the usage of Net::SSL as part of Crypt::SSLeay to make SSL connections is deprecated (version 0.72). As soon as you install that version the module LWP::Protocol::https is pulled from CPAN if it's not installed before. With that installation IO::Socket::SSL should be pulled from CPAN to do the whole SSL stuff in favour of Net::SSL.

So, as soon as you hit the bug you should check why you're using Net::SSL and not IO::Socket::SSL. In my case is seems to be a strange history of dependency resolution.

Regards
McA

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in lib/perl5/Net/HTTP/Methods.pm at can_read, and compare the existing IO::Socket::SSL handling with the reported Net::SSL case. Check how older Crypt::SSLeay versions expose socket methods and determine a backward-compatible resolution for the pending call. Done means Net::SSL connections no longer hang or fail with older supported dependencies.

Written by the indexing model from the issue text.

Assessment

Tech stack
perl
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.