Navkirat Singh wrote:
Aaah figured it out...!!

It was elementary, I was lacking the carriage return and line feed characters at the end of the status and header line. Here is how I solved it:

hostsock.send(b'HTTP/1.1 301 Moved Permanently\r\nLocation: http://www.example.com\r\n')

Regards,
Nav

You might want to note that the .send method doesn't guarantee to send
all the bytes, so you might want to use .sendall instead (it's in the
documentation).

On 23-Jul-2010, at 7:00 AM, Navkirat Singh wrote:

Hi Guys,

I am very new to python and I am trying to send HTTP headers for redirection using sockets in python 3, but in vain. If I use the meta tag REFRESH method the redirection works. Please advise what I am missing, below is the snippet of my code:

hostsock is the socket object


print('Redirecting client') hostsock.send("""HTTP/1.1 301 Moved Permanently
        Location: http://www.example.com"";)


I have been up all night trying to figure this one out : ( I would be grateful if someone could point me in the right direction

Regards,
Nav


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to