I am trying to implement program that determine, if page support tls or not and if it is needed to have prefix www. So I am testing page1.cz and check response status of this objects:
Session().get('http://page1.cz')
<Response [200]>
Session().get('http://www.page1.cz')
<Response [200]>
Session().get('https://page1.cz')
<Response [200]>
Session().get('https://www.page1.cz')
<Response [200]>
It works fine, I know that page1.cz is using https and it is always redirect to https://page1.cz. When I tried page2.cz, I recieved error when testing with https prefix. I receiving this error:
Session().get('http://page2.cz')
<Response [200]>
Session().get('http://www.page2.cz')
<Response [200]>
Session().get('https://page2.cz')
ConnectionError: HTTPSConnectionPool(host='page2.cz', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f75e85f03c8>: Failed to establish a new connection: [Errno 111] Connection refused',))
Session().get('https://www.page2.cz')
ConnectionError: HTTPSConnectionPool(host='www.page2.cz', port=443): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f75e85f03c8>: Failed to establish a new connection: [Errno 111] Connection refused',))
I know that second page does not support https but why that error? It should just return code 4xx or am I wrong? What am I doing wrong and how to check if page support http, https and www prefixes?