examples/network/http_client*: Use \r\n line-endings in request.

pull/2498/head
Paul Sokolovsky 2016-10-09 19:36:04 +03:00
rodzic 3dabaae47d
commit fa5ac678fc
2 zmienionych plików z 4 dodań i 4 usunięć

Wyświetl plik

@ -18,10 +18,10 @@ def main(use_stream=False):
# MicroPython socket objects support stream (aka file) interface
# directly, but the line below is needed for CPython.
s = s.makefile("rwb", 0)
s.write(b"GET / HTTP/1.0\n\n")
s.write(b"GET / HTTP/1.0\r\n\r\n")
print(s.readall())
else:
s.send(b"GET / HTTP/1.0\n\n")
s.send(b"GET / HTTP/1.0\r\n\r\n")
print(s.recv(4096))
s.close()

Wyświetl plik

@ -24,12 +24,12 @@ def main(use_stream=True):
if use_stream:
# Both CPython and MicroPython SSLSocket objects support read() and
# write() methods.
s.write(b"GET / HTTP/1.0\n\n")
s.write(b"GET / HTTP/1.0\r\n\r\n")
print(s.read(4096))
else:
# MicroPython SSLSocket objects implement only stream interface, not
# socket interface
s.send(b"GET / HTTP/1.0\n\n")
s.send(b"GET / HTTP/1.0\r\n\r\n")
print(s.recv(4096))
s.close()