byorgey / haxr

Other
10 stars 16 forks source link

please document: default port 443 #15

Closed jwaldmann closed 8 years ago

jwaldmann commented 8 years ago

Hi,

I needed several hours (over several days) to find out why my application stopped working: because you switched the default port to 443. ( https://gitlab.imn.htwk-leipzig.de/autotool/all/issues/19 )

This looks very strange, especially if the server adress contains the protocol name (as it should), as in http://foo.bar/whatever. Only after wiresharking, and studying the source, I found that I have to http://foo.bar:80/whatever.

Would the "simple client example" work at all? https://hackage.haskell.org/package/haxr-3000.11.1.5/docs/Network-XmlRpc-Client.html

If this was intended, then this calls for an update in the documentation.

Or is it just a bug? I think the part "depending on URL" is not true:

3000.11.1 (10 July 2015)
  - Support both HTTP and HTTPS automatically, depending on URL.

I think the code is wrong because you pick the default port outside the "case".

    let hostname = BS.pack (uriRegName auth)
        port     = fromMaybe 443 (readMaybe $ drop 1 $ uriPort auth)

    c <- case init $ uriScheme uri of
        "http"  ->
            openConnection hostname port
        "https" -> do
            ctx <- baselineContextSSL
            openConnectionSSL ctx hostname port

I will submit a trivial patch.