Size of a remote URL

Dave Brueck dave at pythonapocrypha.com
Mon Aug 30 16:19:17 EDT 2004


Justin wrote:

> Ok so the problem is that my code is not requesting the headers
> properly.  I get back.  Just that.  I don't know what the difference is
> between the IE request and mine

Try this:

from socket import *
s = socket(AF_INET, SOCK_STREAM)
s.bind(('',8000))
s.listen(1)

while 1:
   q,v = s.accept()
   print 'Got connection:'
   data = ''
   while 1:
     more = q.recv(8192)
     if not more: break
     data += more
     if data.find('\r\n\r\n') != -1:
       break


Now replace the domain name in the real URL with "127.0.0.1:8000". Feed the URL 
to IE and to your app & compare the output displayed by your "server".

-Dave



More information about the Python-list mailing list