Yoav Weiss <yoav.weiss...@gmail.com> added the comment:
Thanks for correcting me. I guess I assumed that the "message" variable is
an HTTPMessage.
Is send_response documented somewhere? I failed to find a reference.
On Sun, Jul 3, 2011 at 9:45 PM, Petri Lehtinen <rep...@bugs.python.org>wrote:
>
> Petri Lehtinen <pe...@digip.org> added the comment:
>
> It seems to me that you're indeed misusing it.
>
> The correct way would be something like this (assuming response is a
> HTTPResponse object from httplib):
>
> self.send_response(response.status)
> for name, value in response.getheaders():
> self.send_header(name, value)
> self.end_headers()
>
> This is because send_response's second argument is the HTTP's "reason"
> field, i.e. invoking:
>
> self.send_response(123, 'FOOBAR')
>
> results in
>
> HTTP/1.1 123 FOOBAR\r\n
>
> to be sent, followed by "Server" and "Date" headers. The second argument is
> not meant to be used for sending headers.
>
> (When the second argument is omitted, a standard reason for the given
> status code is used.)
>
> ----------
> nosy: +petri.lehtinen
> resolution: -> invalid
>
> _______________________________________
> Python tracker <rep...@bugs.python.org>
> <http://bugs.python.org/issue12439>
> _______________________________________
>
----------
Added file: http://bugs.python.org/file22565/unnamed
_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12439>
_______________________________________
Thanks for correcting me. I guess I assumed that the "message"
variable is an HTTPMessage.<div>Is send_response documented somewhere? I failed
to find a reference.</div><div><br></div><div><br><div class="gmail_quote">
On Sun, Jul 3, 2011 at 9:45 PM, Petri Lehtinen <span dir="ltr"><<a
href="mailto:rep...@bugs.python.org">rep...@bugs.python.org</a>></span>
wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Petri Lehtinen <<a href="mailto:pe...@digip.org">pe...@digip.org</a>>
added the comment:<br>
<br>
It seems to me that you're indeed misusing it.<br>
<br>
The correct way would be something like this (assuming response is a
HTTPResponse object from httplib):<br>
<br>
self.send_response(response.status)<br>
for name, value in response.getheaders():<br>
  self.send_header(name, value)<br>
self.end_headers()<br>
<br>
This is because send_response's second argument is the HTTP's
"reason" field, i.e. invoking:<br>
<br>
  self.send_response(123, 'FOOBAR')<br>
<br>
results in<br>
<br>
  HTTP/1.1 123 FOOBAR\r\n<br>
<br>
to be sent, followed by "Server" and "Date" headers. The
second argument is not meant to be used for sending headers.<br>
<br>
(When the second argument is omitted, a standard reason for the given status
code is used.)<br>
<br>
----------<br>
nosy: +petri.lehtinen<br>
resolution: Â -> invalid<br>
<div><div></div><div class="h5"><br>
_______________________________________<br>
Python tracker <<a
href="mailto:rep...@bugs.python.org">rep...@bugs.python.org</a>><br>
<<a href="http://bugs.python.org/issue12439"
target="_blank">http://bugs.python.org/issue12439</a>><br>
_______________________________________<br>
</div></div></blockquote></div><br></div>
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com