Thread [Perl 5.22] LWP, SSL und Bad file descriptor (28 answers)
Opened by rosti at 2025-02-14 12:51

rosti
 2025-02-14 12:51
#196861 #196861
User since
2011-03-19
3530 Artikel
BenutzerIn
[Homepage]
user image
Moin, mal wieder LWP. Da kriege ich

Code: (dl )
1
2
3
4
5
6
7
8
500 Can't connect to www.rationalgalerie.de:443
Content-Type: text/plain
Client-Date: Fri, 14 Feb 2025 11:49:19 GMT
Client-Warning: Internal response

Can't connect to www.rationalgalerie.de:443

Bad file descriptor at C:/Perl64/lib/LWP/Protocol/http.pm line 47.


Und hier mein Perl
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package XHR; # Analog zu JavaScript XHR

use strict;
use warnings;
use HTTP::Request;
use LWP::UserAgent;

sub new{
    my $class = shift;
    my $callback = shift;
    bless { ua => LWP::UserAgent->new(), cb => $callback }, $class;
}
sub request{
    my $self = shift;
    my %par = (
        method  => 'GET',
        uri     => '',
        content => '',
        header  => [],
        @_    
    );
    my $r = HTTP::Request->new( @par{qw(method uri header content)} );
    my $res = $self->{ua}->request($r);
    $self->{cb}->($res);
}
###########################################################################
package main;

use strict;
use warnings;

sub callback{
    my $self = shift; # Response Objekt
    print $self->as_string;
}

my $xhr = new XHR(*callback);
$xhr->request(
    uri => 'https://www.rationalgalerie.de/',
);


Whats wrong?

PS: Mit Request an uri => 'https://example.com'  keine Fehler übrigens.
Last edited: 2025-02-14 12:53:45 +0100 (CET)

View full thread [Perl 5.22] LWP, SSL und Bad file descriptor