Question...

Steve Holden sholden at holdenweb.com
Tue Jul 31 19:30:35 EDT 2001


"Adonis Vargas" <deltapigz at telocity.com> wrote in message
news:3B6737BE.2CCC0A1A at telocity.com...
> how come this code does not seem to popup on any broswer i attempt to
> send HTML data to:
>
>     (c, a) = s.accept()
>     c.send('HTTP 200 OK\n')

Strictly according to the protocol that should be "HTTP/1.0 200 OK" or some
other string including a version.

>     c.send('Content-Type: text/html\n')
>     c.send('')
>     print RED + "CONNECT->%s"%a[0] + RESET
>
>     d = c.recv(256)

At the moment the browser has the HTTP headers winging their way towards it,
with no terminating blank line. What are you expecting to receive? Since the
browser won't close the socket either (it's still waiting for the
termination of the headers) it won't close its end of the socket either, so
your program stops here. Only for an hour or two while the connection times
out, though 8-)

>     c.send("""
>           <HTML>
>           <HEAD>
>           <TITLE>Redirecting...</TITLE>
>           <META http-equiv="refresh" content="0;
> url=http://www.python.org/">
>           </HEAD>
>           <BODY>
>           </BODY>
>           </HTML>\n
>           """)
>     c.close()
>
> *basic idea to redirect a broswer.
>
> any help would greatly be appreciated.
>
Does this help?

regards
 Steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list