I am new to python and network programming and I am having trouble with a simple program. I am basically opening a connection to a nonexistent website and somehow it seems that the connection succeeds. Moreover, I get a 200 return code which means the http server has responded that it exists and the connection is OK. Here’s the relevant part of my code:
import httplib
conn = httplib.HTTPConnection("Nonexistentsite.com", 80)
conn.request("GET","/")
r = conn.getresponse()
print r.status, r.reason
conn.close()
And when I try google.com or any other existing website instead of nonexistentsite.com, I get 301 or 302 – Moved permanently.
Could you kindly clarify why this is happening, please? I am using visualStudio2010(IronPython) if that matters.
You might be using an ISP that fakes DNS results in order to give you a
spam pagehelpful search page instead of an error for nonexistant names.What does a
ping Nonexistentsite.comresult in on the machine where you tested your Python code?