Skip to content

why was AI_NUMERICHOST removed in http-client-openssl?  #526

Description

@MangoIV

in withSocket we always pass port to NS.getAddrInfo, but we don't pass a hint that the underlying c function is called with a numeric serviceName, that was once the case, so I wonder why that would be removed.

If it was accidental, the fix would be as simple as

diff --git a/http-client/Network/HTTP/Client/Connection.hs b/http-client/Network/HTTP/Client/Connection.hs
index 823072bd..c29407f6 100644
--- a/http-client/Network/HTTP/Client/Connection.hs
+++ b/http-client/Network/HTTP/Client/Connection.hs
@@ -193,7 +193,7 @@ withSocket :: (Socket -> IO ())
            -> (Socket -> IO a)
            -> IO a
 withSocket tweakSocket hostAddress' host' port' f = do
-    let hints = NS.defaultHints { NS.addrSocketType = NS.Stream }
+    let hints = NS.defaultHints { NS.addrSocketType = NS.Stream, NS.addrFlags = [ NS.AI_NUMERICSERV, NS.AI_ADDRCONFIG ] }
     addrs <- case hostAddress' of
         Nothing ->
             NS.getAddrInfo (Just hints) (Just $ strippedHostName host') (Just $ show port')

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions