This is my code:
import socket
mysock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
mysock.connect(('www.py4inf.com', 80))
mysock.send(b'GET http://www.py4inf.com/code/romeo.txt HTTP/1.0\n\n')
while True:
data = mysock.recv(1024)
if ( len(data) < 1 ) :
break
print(data)
mysock.close()
and the output is:
b'HTTP/1.1 200 OK\r\n
Date: Thu, 17 Mar 2016 01:45:49 GMT\r\n
Server: Apache\r\nLast-Modified: Fri, 04 Dec 2015 19:05:04 GMT\r\n
ETag: "e103c2f4-a7-526172f5b5d89"\r\n
Accept-Ranges: bytes\r\n
Content-Length: 167\r\n
Cache-Control: max-age=604800, public\r\n
Access-Control-Allow-Origin: *\r\n
Access-Control-Allow-Headers: origin, x-requested-with, content-type\r\n
Access-Control-Allow-Methods: GET\r\n
Connection: close\r\n
Content-Type: text/plain\r\n
\r\n
But soft what light through yonder window breaks\n
It is the east and Juliet is the sun\n
Arise fair sun and kill the envious moon\n
Who is already sick and pale with grief\n'
however, I want it to be:
But soft what light through yonder window breaks
It is the east and Juliet is the sun
Arise fair sun and kill the envious moon
Who is already sick and pale with grief
so what should I do?