sergot / http-useragent

Web user agent class for Perl 6.
MIT License
36 stars 39 forks source link

Installation fail on Windows 7 64bit #205

Closed vnluc closed 4 years ago

vnluc commented 6 years ago

I am using version 2018.05

When I try install command, this is the output of error.

zef install HTTP::UserAgent

===> Searching for: HTTP::UserAgent
===> Testing: HTTP::UserAgent:ver<1.1.44>:auth<github:sergot>
# NETWORK_TESTING was not set
# NETWORK_TESTING was not set
# NETWORK_TESTING was not set
# NETWORK_TESTING was not set
# NETWORK_TESTING was not set
# NETWORK_TESTING was not set
# NETWORK_TESTING was not set
    # Failed test 'right exception type (HTTP::UserAgent::Exception::X::HTTP::Internal)'
    # at C:\rakudo\rakudo-2018.05\install\share\perl6\precomp\5F6F604EACBEA385FA41726F599A10851BCB6154\C7\C712FE6969F786C9380D643DF17E85D06868219E line 1
    # Expected: HTTP::UserAgent::Exception::X::HTTP::Internal
    # Got:      X::AdHoc
    # Exception message: Could not receive data from socket: An established connection was aborted by the software in your host machine.

    # Looks like you failed 1 test of 3
# Failed test 'throws the correct exception'
# at t/250-issue-144.t line 28
# Looks like you failed 1 test of 1
===> Testing [FAIL]: HTTP::UserAgent:ver<1.1.44>:auth<github:sergot>
ufobat commented 5 years ago

I've just experienced the same. Windows 10 with rakudo 2018-10.

jonathanstowe commented 5 years ago

The reason for this is that the error message is matched for the "Connection reset by peer" condition, and Windows actually says "An established connection was aborted" in the condition we were testing for.

I guess this would fix it:

diff --git a/lib/HTTP/UserAgent.pm6 b/lib/HTTP/UserAgent.pm6
index c0762f9..dda4ac8 100644
--- a/lib/HTTP/UserAgent.pm6
+++ b/lib/HTTP/UserAgent.pm6
@@ -274,7 +274,7 @@ method get-response(HTTP::Request $request, Connection $conn, Bool :$bin) return
         when X::HTTP::NoResponse {
             X::HTTP::Internal.new(rc => 500, reason => "server returned no data").throw;
         }
-        when /'Connection reset by peer'/ {
+        when /'Connection reset by peer' || 'An established connection was aborted'/ {
             X::HTTP::Internal.new(rc => 500, reason => "Connection reset by peer").throw;
         }
     }

But as I can't test on Windows I'm somewhat loathe to just stick it in without it being tested first.

ufobat commented 5 years ago

well... not on german windows installations :-(

# Failed test 'right exception type (HTTP::UserAgent::Exception::X::HTTP::Internal)'                                                                                                                               
# at C:\rakudo\share\perl6\precomp\27817378A664BB5C15126CB10AFCD197C0389145\C7\C712FE6969F786C9380D643DF17E85D06868219E line 1 
# Expected: HTTP::UserAgent::Exception::X::HTTP::Internal                                                                                                                                                         
# Got:      X::AdHoc                                                                                                                                                                                              
# Exception message: Could not receive data from socket: Eine bestehende Verbindung wurde softwaregesteuert 
durch den Hostcomputer abgebrochen.  

or is this something related but different?

jonathanstowe commented 5 years ago

Well it would appear that it is just passing the text from the OS verbatim, and Windows has internationalised error messages for this. I assume also that the Could not receive data from socket is common to a number of potential error conditions, so it's going to be tricky to match.

I guess the proper fix would be for Perl 6 to throw properly typed exceptions in IO::Socket::INET so we wouldn't have to worry about matching the error text.

hankache commented 4 years ago

This is still failing on Windows. Rakudo 2019.07.1

Any idea why it is failing? Is it something specific to Windows that is not working? Shall we skip this test if we are on Windows?

jonathanstowe commented 4 years ago

The reason that it fails is that IO::Socket::INET throws an AdHoc exception for the 'connection reset by peer' case with the text of the OS error as the message, the code that is being tested matches the 'connection reset by peer' to detect this particular error. For most Unix like operating systems this is fine as the message is fairly consistently what is expected, however on Windows the message is different and localised to the locale set in the OS so the exception doesn't match.

I'd go with marking the test as TODO on Windows to be honest. The real fix would be to make IO::Socket::INET throw more specific exceptions which can be tested explicitly.

hankache commented 4 years ago

This is fixed on windows

hankache commented 4 years ago

I think this can be closed, no?

jonathanstowe commented 4 years ago

We'll close when we get three or four :+1: on the above comment :-)

hankache commented 4 years ago

@jonathanstowe does my vote count? ;)

jonathanstowe commented 4 years ago

Of course :-)