You should be able to do
HTTP(400,**{'Content-Type':'text/html'})
On Friday, 20 July 2012 14:41:19 UTC-5, tiadobatima wrote:
>
> Hi Massimo,
>
> I see. But how do I set the Content-Type when raising HTTP(400)?
> I'm assuming this Content-Type set automatically when when the exception
> is raised. Do I have any control over it?
>
> Thanks :)
> g.
>
> On Friday, 20 July 2012 11:49:58 UTC-7, Massimo Di Pierro wrote:
>>
>> The rest about should not have:
>> self.headers['Content-Type'].startswith('text/html')
>>
>> If they do you need the extra comment else IE will not display the rest
>> of the error message.
>>
>> On Friday, 20 July 2012 12:22:50 UTC-5, tiadobatima wrote:
>>>
>>>
>>> Hi guys,
>>>
>>> Raising a 4xx exception is printing extra 512 'x' characters in the
>>> body. This seems to be the culprit (HTTP.py):
>>>
>>>
>>> if len(body)<512 and self.headers['Content-Type'].startswith(
>>> 'text/html'):
>>> body += '<!-- %s //-->' % ('x'*512) ### trick IE
>>>
>>> Is there any easy way of not printing these extra characters without
>>> chaging HTTP.py?
>>> Long term, It would be nice if there was switch to turn this off, maybe
>>> an user-agent argument in the constructor?
>>> The current behaviour is not great for REST APIs.
>>>
>>> Thanks! :)
>>> g.
>>>
>>
--