davecheney / httpstat

It's like curl -v, with colours.
MIT License
7.07k stars 385 forks source link

Can't connect to host if it can't work with HTTPS #92

Closed n10v closed 8 years ago

n10v commented 8 years ago

I can't connect to host, if it works only with HTTP, without obvious declaration of protocol: 2016-09-28 13 55 46

davecheney commented 8 years ago

This is a deliberate choice to default to https if no scheme is provided.

What error message would you like to see in this case?

n10v commented 8 years ago

I think, in this case it would be perfect, if httpstat would check the support of HTTPS protocol on site. So if httpstat could't connect to site with HTTPS, it would connect to it with HTTP.

davecheney commented 8 years ago

Sorry, that's beyond the remit of this tool. I think we're already doing more than we should by trying to guess the scheme if one is not provided.

n10v commented 8 years ago

Then error message could be like "Can't connect to host with HTTPS. Please provide a scheme to URL"

davecheney commented 8 years ago

If we're going to do that, then I'd prefer to drop the automatic scheme prefix and just say "not a url, try again".

n10v commented 8 years ago

Yeah, it's a good idea too

moorereason commented 8 years ago

What if we output "Connecting to ..." prior to dialing? Example:

$ httpstat dave.cheney.net
Connecting to https://dave.cheney.net

2016/09/28 10:19:46 unable to connect to host 128.199.248.140:443 dial tcp 128.199.248.140:443: getsockopt: connection refused
exit status 1

Normal operation:

$ httpstat http://dave.cheney.net
Connecting to http://dave.cheney.net

Connected to 128.199.248.140:80

HTTP/1.1 200 OK
Server: nginx/1.2.1
Content-Type: text/html; charset=UTF-8
Date: Wed, 28 Sep 2016 15:21:04 GMT
Link: <http://dave.cheney.net/wp-json/>; rel="https://api.w.org/"
X-Powered-By: PHP/5.4.45-0+deb7u2
Connection: keep-alive

Body discarded

   DNS Lookup   TCP Connection   Server Processing   Content Transfer
[      44ms  |         228ms  |            539ms  |           455ms  ]
             |                |                   |                  |
    namelookup:44ms           |                   |                  |
                        connect:273ms             |                  |
                                      starttransfer:813ms            |
                                                                 total:1268ms
davecheney commented 8 years ago

I'm not down with more output, the next thing people will ask for is a flag to turn these two lines off.

On Thu, 29 Sep 2016, 01:23 Cameron Moore notifications@github.com wrote:

What if we output "Connecting to ..." prior to dialing? Example:

$ httpstat dave.cheney.net Connecting to https://dave.cheney.net

2016/09/28 10:19:46 unable to connect to host 128.199.248.140:443 dial tcp 128.199.248.140:443: getsockopt: connection refused exit status 1

Normal operation:

$ httpstat http://dave.cheney.net Connecting to http://dave.cheney.net

Connected to 128.199.248.140:80

HTTP/1.1 200 OK Server: nginx/1.2.1 Content-Type: text/html; charset=UTF-8 Date: Wed, 28 Sep 2016 15:21:04 GMT Link: http://dave.cheney.net/wp-json/; rel="https://api.w.org/" X-Powered-By: PHP/5.4.45-0+deb7u2 Connection: keep-alive

Body discarded

DNS Lookup TCP Connection Server Processing Content Transfer [ 44ms 228ms 539ms 455ms ]
namelookup:44ms
connect:273ms
starttransfer:813ms
                                                             total:1268ms

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/davecheney/httpstat/issues/92#issuecomment-250200794, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAcAxJ5ACBXI2m1WQcCfNLgJ0NTxuGdks5quoaFgaJpZM4KIu8P .

davecheney commented 8 years ago

I'm going to close this issue as working as intended. The result is surprising, but intended, due to the deliberate decision to prefer https over http when no scheme is provided by the user.