What is needed for the browser, Safari and Opera, in particular, to understand the HTTP response?

I have an HTTP response

HTTP/1.0 200 OK\r\n\r\n
<!DOCTYPE html>...

Both Firefox and Chrome seem to understand it perfectly and display HTML content - however, Safari and Opera just show me everything in clear text. Adding a "Content-Type" field will hinder everyone for all browsers.

What is the catch?

I will not publish the full code, because there is a lot of arbitrary programming logic that is not related to the problem, however, something like this:

I create a socket, then all the socket operations associated with it happen - it all works like magic, and then all the I.send processing ("answer here"), and for some reason it only appears in Firefox and Chrome.

The response line looks like this:

'''
HTTP/1.1 200 OK\r\n
<!DOCTYPE html>
...
...
</html>
'''

, : http://cl.ly/0y0U1s0G3X2v1C11282S

+3
1

, , :

'''
HTTP/1.1 200 OK\r\n
<!DOCTYPE html>
...
'''

Python \n, . , , ,

HTTP/1.1 200 OK\r\n\n<!DOCTYPE html>...

, \r. :

sock.send("HTTP/1.1 200 OK\r\n\r\n")

Content-type:

sock.send("HTTP/1.1 200 OK\r\nContent-type: text/html\r\n\r\n")

:

sock.send('''
<!DOCTYPE html>
...
''')

. \r\n , .

+5
source

All Articles