I identified root cause:
google.com is a bit sloppy, other http[s] servers need at least "Host" header presented!
I fixed both network http[s] client examples, see this commit on my micropython fork for details:
https://github.com/Hermann-SW/micropyth ... cf85fbb86d
Now both work with unix micropython port (eg. http example)
Code: Select all
pi@raspberrypi4B:~/pico/micropython/ports/unix $ ./micropython ../../examples/network/http_client.py
Address infos: [(2, 1, 6, None, bytearray(b'\x02\x00\x00PA\tE\xb1\x00\x00\x00\x00\x00\x00\x00\x00')), (2, 2, 17, None, bytearray(b'\x02\x00\x00PA\tE\xb1\x00\x00\x00\x00\x00\x00\x00\x00')), (2, 3, 0, None, bytearray(b'\x02\x00\x00PA\tE\xb1\x00\x00\x00\x00\x00\x00\x00\x00')), (2, 1, 6, None, bytearray(b'\x02\x00\x00PA\tE\xb8\x00\x00\x00\x00\x00\x00\x00\x00')), (2, 2, 17, None, bytearray(b'\x02\x00\x00PA\tE\xb8\x00\x00\x00\x00\x00\x00\x00\x00')), (2, 3, 0, None, bytearray(b'\x02\x00\x00PA\tE\xb8\x00\x00\x00\x00\x00\x00\x00\x00')), (2, 1, 6, None, bytearray(b'\x02\x00\x00PA\tEx\x00\x00\x00\x00\x00\x00\x00\x00')), (2, 2, 17, None, bytearray(b'\x02\x00\x00PA\tEx\x00\x00\x00\x00\x00\x00\x00\x00')), (2, 3, 0, None, bytearray(b'\x02\x00\x00PA\tEx\x00\x00\x00\x00\x00\x00\x00\x00')), (2, 1, 6, None, bytearray(b'\x02\x00\x00PA\tE\x05\x00\x00\x00\x00\x00\x00\x00\x00')), (2, 2, 17, None, bytearray(b'\x02\x00\x00PA\tE\x05\x00\x00\x00\x00\x00\x00\x00\x00')), (2, 3, 0, None, bytearray(b'\x02\x00\x00PA\tE\x05\x00\x00\x00\x00\x00\x00\x00\x00'))]
Connect address: bytearray(b'\x02\x00\x00PA\tE\xb1\x00\x00\x00\x00\x00\x00\x00\x00')
b'HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: 2536\r\nLast-Modified: Thu, 19 Nov 2020 22:29:21 GMT\r\nAccept-Ranges: bytes\r\nServer: AmazonS3\r\nDate: Thu, 22 Apr 2021 06:35:14 GMT\r\nETag: "e8bb9152091d61caa9d69fed8c4aebc6"\r\nVary: Accept-Encoding\r\nX-Cache: Hit from cloudfront\r\nX-Amz-Cf-Pop: FRA56-C1\r\nX-Amz-Cf-Id: KjXhCDjU-DpeNgjhqq-75fSvu2uyc3C5-FZWYsJWpw5Jh20YMuG7TA==\r\nAge: 8063\r\nX-Cache: HIT from uni-heidelberg.eSienet.de\r\nX-Cache-Lookup: HIT from uni-heidelberg.eSienet.de:8080\r\nVia: 1.1 d947c3ab534102b2c9a7f0a4541d2ed9.cloudfront.net (CloudFront), 1.1 uni-heidelberg.eSienet.de (squid/4.4)\r\nConnection: close\r\n\r\n<html>\n <head>\n <title>NeverSSL - helping you get online</title>\n\n <style>\n body {\n font-family: Montserrat, helvetica, arial, sans-serif; \n font-size: 16x;\n color: #444444;\n margin: 0;\n }\n h2 {\n font-weight: 700;\n font-size: 1.6em;\n margin-top: 30px;\n }\n p {\n line-height: 1.6em;\n }\n .container {\n max-width: 650px;\n margin: 20px auto 20px auto;\n padding-left: 15px;\n padding-right: 15px\n }\n .header {\n background-color: #42C0FD;\n color: #FFFFFF;\n padding: 10px 0 10px 0;\n font-size: 2.2em;\n }\n <!-- CSS from Mark Webster https://gist.github.com/markcwebster/9'
pi@raspberrypi4B:~/pico/micropython/ports/unix $
as well as with python3 (eg. https example):
Code: Select all
pi@raspberrypi4B:~/pico/micropython/ports/unix $ python3 ../../examples/network/http_client_ssl.py
Address infos: [(2, 1, 6, '', ('93.90.177.145', 443)), (2, 2, 17, '', ('93.90.177.145', 443)), (2, 3, 0, '', ('93.90.177.145', 443))]
Connect address: ('93.90.177.145', 443)
<ssl.SSLSocket fd=3, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('10.14.247.224', 58898), raddr=('93.90.177.145', 443)>
b'HTTP/1.1 200 OK\r\nServer: nginx\r\nDate: Thu, 22 Apr 2021 08:50:49 GMT\r\nContent-Type: text/html; charset=UTF-8\r\nContent-Length: 290\r\nConnection: close\r\nVary: Accept-Encoding\r\nAccess-Control-Allow-Origin: *\r\nVary: Accept-Encoding\r\n\r\n<pre>60000\n\n.........\n... ...\n... ...\n. .\n. oo .\n. .\n... ...\n... ...\n.........\n\n.........\n... ...\n... ...\n. .\n. oX .\n. .\n... ...\n... ...\n.........\n\n.........\n... ...\n... ...\n. .\n. o .\n. .\n... ...\n... ...\n.........\n</pre>'
pi@raspberrypi4B:~/pico/micropython/ports/unix $