Re: No 'Content-Type' header in response

2016-12-27 Thread Tim Graham
Don't worry about the unrelated failures, hopefully we'll get that other PR 
merged soon.

On Tuesday, December 27, 2016 at 12:01:36 AM UTC-5, roboslone wrote:
>
> Okay, so I've submitted a pull-request 
>  resolving this issue. But 
> tests for timesince, timeuntil are still broken. I believe #27637 
>  (PR 
> ) fixes them.
> Do I need to do anything to fix those tests in my PR? Merging felixmm's PR 
> in my fork doesn't seem right.
>
> On 27 Dec 2016, at 06:36, roboslone > 
> wrote:
>
> Oh, nevermind. Instructions are attached to the ticket. I'll start to work 
> on this.
>
> On 27 Dec 2016, at 06:33, roboslone > 
> wrote:
>
> So how can I help resolve this? Should I just fork Django on GitHub and 
> make a pull-request?
>
> On 26 Dec 2016, at 15:45, Curtis Maloney  > wrote:
>
> From what I can see in the rfc, it is permitted but not required.
>
> Only a body in a 204 response is proscribed.
>
> Any metadata (I.e. headers) are about the resource just accessed... So a 
> Content-Type would, IMHO, be acceptable but not essential.
>
>
>
> On 26 December 2016 9:47:02 PM AEDT, roboslone  > wrote:
>>
>> Thanks, that was an old setting in Mail.app =/
>>
>> I've made a pull-request to DRF: 
>> https://github.com/tomchristie/django-rest-framework/pull/4768
>> But it seems to me that fixing it in Django would be more appropriate.
>>
>> On the subject of Content-Type header with no response body, seems 
>> there's no convention about it, I've found different opinions on the web. 
>> The only thing I'm sure about is that putting None in that header is a bad 
>> idea.
>>
>> On 26 Dec 2016, at 13:24, Adam Johnson > 
>> wrote:
>>
>> Hi GMail! (you might want to fix your name used on google groups, I had 
>> the same problem ;) )
>>
>> This seems to be a legitimate bug in the __repr__ to me - SO informs me 
>> that DRF is correct in not defining a Content-Type for a 204 as it has no 
>> body: 
>> https://stackoverflow.com/questions/21029351/what-content-type-should-a-204-no-response-use
>>
>> I created a ticket: https://code.djangoproject.com/ticket/27640 . If you 
>> want to try fix it there's a great contribution guide at 
>> https://docs.djangoproject.com/en/dev/internals/contributing/ . I think 
>> using str.format would be acceptable, but the dict subclass sounds more 
>> complicated than just doing self.get('Content-Type', '') :)
>>
>> On 26 December 2016 at 05:57, GMail > 
>> wrote:
>>
>>> Hi! I'm using Django 1.10.2 and Django-Rest-Framework 3.5.3.
>>> I noticed, that HttpRequest.__repr__ method relies on 'Content-Type' 
>>> header:
>>>
>>>
>>> > class HttpResponse(HttpResponseBase):
>>> > ...
>>> >
>>> > def __repr__(self):
>>> > return '<%(cls)s status_code=%(status_code)d, 
>>> "%(content_type)s">' % {
>>> > 'cls': self.__class__.__name__,
>>> > 'status_code': self.status_code,
>>> > 'content_type': self['Content-Type'],
>>> > }
>>>
>>>
>>> And after deleting an object in DRF sends empty response with HTTP204 
>>> and no 'Content-Type' header. I was trying to log outgoing response and got 
>>> KeyError here.
>>>
>>> So I have two questions:
>>> 1. Is this intentional? Do all responses in Django have 'Content-Type' 
>>> header and should DRF be aware of it?
>>> 2. Why not use `str.format` here? To avoid errors like this, `dict` 
>>> subclass with `__missing__` method could be used.
>>>
>>> --
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django developers  (Contributions to Django itself)" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-develop...@googlegroups.com .
>>> To post to this group, send email to django-d...@googlegroups.com 
>>> .
>>> Visit this group at https://groups.google.com/group/django-developers.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-developers/39F85D40-019C-411A-BCA7-402E338EA527%40gmail.com
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>> Adam
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django developers (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-develop...@googlegroups.com .
>> To post to this group, send email to django-d...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-developers.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-developers/CAMyDDM39qZj7fV-MvPX%2BtXvSNL9%2B80283Aa5P47uBh3D46Q8BQ%40mail.gmail.com
>>  
>> 
>> .
>> For 

Re: No 'Content-Type' header in response

2016-12-26 Thread roboslone
Okay, so I've submitted a pull-request 
 resolving this issue. But tests 
for timesince, timeuntil are still broken. I believe #27637 
 (PR 
) fixes them.
Do I need to do anything to fix those tests in my PR? Merging felixmm's PR in 
my fork doesn't seem right.

> On 27 Dec 2016, at 06:36, roboslone  wrote:
> 
> Oh, nevermind. Instructions are attached to the ticket. I'll start to work on 
> this.
> 
>> On 27 Dec 2016, at 06:33, roboslone > > wrote:
>> 
>> So how can I help resolve this? Should I just fork Django on GitHub and make 
>> a pull-request?
>> 
>>> On 26 Dec 2016, at 15:45, Curtis Maloney >> > wrote:
>>> 
>>> From what I can see in the rfc, it is permitted but not required.
>>> 
>>> Only a body in a 204 response is proscribed.
>>> 
>>> Any metadata (I.e. headers) are about the resource just accessed... So a 
>>> Content-Type would, IMHO, be acceptable but not essential.
>>> 
>>> 
>>> 
>>> On 26 December 2016 9:47:02 PM AEDT, roboslone >> > wrote:
>>> Thanks, that was an old setting in Mail.app =/
>>> 
>>> I've made a pull-request to DRF: 
>>> https://github.com/tomchristie/django-rest-framework/pull/4768 
>>> 
>>> But it seems to me that fixing it in Django would be more appropriate.
>>> 
>>> On the subject of Content-Type header with no response body, seems there's 
>>> no convention about it, I've found different opinions on the web. The only 
>>> thing I'm sure about is that putting None in that header is a bad idea.
>>> 
 On 26 Dec 2016, at 13:24, Adam Johnson >>> > wrote:
 
 Hi GMail! (you might want to fix your name used on google groups, I had 
 the same problem ;) )
 
 This seems to be a legitimate bug in the __repr__ to me - SO informs me 
 that DRF is correct in not defining a Content-Type for a 204 as it has no 
 body: 
 https://stackoverflow.com/questions/21029351/what-content-type-should-a-204-no-response-use
  
 
 
 I created a ticket: https://code.djangoproject.com/ticket/27640 
  . If you want to try fix it 
 there's a great contribution guide at 
 https://docs.djangoproject.com/en/dev/internals/contributing/ 
  . I think 
 using str.format would be acceptable, but the dict subclass sounds more 
 complicated than just doing self.get('Content-Type', '') :)
 
 On 26 December 2016 at 05:57, GMail >>> > wrote:
 Hi! I'm using Django 1.10.2 and Django-Rest-Framework 3.5.3.
 I noticed, that HttpRequest.__repr__ method relies on 'Content-Type' 
 header:
 
 
 > class HttpResponse(HttpResponseBase):
 > ...
 >
 > def __repr__(self):
 > return '<%(cls)s status_code=%(status_code)d, 
 > "%(content_type)s">' % {
 > 'cls': self.__class__.__name__,
 > 'status_code': self.status_code,
 > 'content_type': self['Content-Type'],
 > }
 
 
 And after deleting an object in DRF sends empty response with HTTP204 and 
 no 'Content-Type' header. I was trying to log outgoing response and got 
 KeyError here.
 
 So I have two questions:
 1. Is this intentional? Do all responses in Django have 'Content-Type' 
 header and should DRF be aware of it?
 2. Why not use `str.format` here? To avoid errors like this, `dict` 
 subclass with `__missing__` method could be used.
 
 --
 You received this message because you are subscribed to the Google Groups 
 "Django developers  (Contributions to Django itself)" group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to django-developers+unsubscr...@googlegroups.com 
 .
 To post to this group, send email to django-developers@googlegroups.com 
 .
 Visit this group at https://groups.google.com/group/django-developers 
 .
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/django-developers/39F85D40-019C-411A-BCA7-402E338EA527%40gmail.com
  
 .
 For more options, visit https://groups.google.com/d/optout 
 .
 
 
 
 -- 
 Adam
 
 -- 
 You received this message because you 

Re: No 'Content-Type' header in response

2016-12-26 Thread roboslone
Oh, nevermind. Instructions are attached to the ticket. I'll start to work on 
this.

> On 27 Dec 2016, at 06:33, roboslone  wrote:
> 
> So how can I help resolve this? Should I just fork Django on GitHub and make 
> a pull-request?
> 
>> On 26 Dec 2016, at 15:45, Curtis Maloney > > wrote:
>> 
>> From what I can see in the rfc, it is permitted but not required.
>> 
>> Only a body in a 204 response is proscribed.
>> 
>> Any metadata (I.e. headers) are about the resource just accessed... So a 
>> Content-Type would, IMHO, be acceptable but not essential.
>> 
>> 
>> 
>> On 26 December 2016 9:47:02 PM AEDT, roboslone > > wrote:
>> Thanks, that was an old setting in Mail.app =/
>> 
>> I've made a pull-request to DRF: 
>> https://github.com/tomchristie/django-rest-framework/pull/4768 
>> 
>> But it seems to me that fixing it in Django would be more appropriate.
>> 
>> On the subject of Content-Type header with no response body, seems there's 
>> no convention about it, I've found different opinions on the web. The only 
>> thing I'm sure about is that putting None in that header is a bad idea.
>> 
>>> On 26 Dec 2016, at 13:24, Adam Johnson >> > wrote:
>>> 
>>> Hi GMail! (you might want to fix your name used on google groups, I had the 
>>> same problem ;) )
>>> 
>>> This seems to be a legitimate bug in the __repr__ to me - SO informs me 
>>> that DRF is correct in not defining a Content-Type for a 204 as it has no 
>>> body: 
>>> https://stackoverflow.com/questions/21029351/what-content-type-should-a-204-no-response-use
>>>  
>>> 
>>> 
>>> I created a ticket: https://code.djangoproject.com/ticket/27640 
>>>  . If you want to try fix it 
>>> there's a great contribution guide at 
>>> https://docs.djangoproject.com/en/dev/internals/contributing/ 
>>>  . I think 
>>> using str.format would be acceptable, but the dict subclass sounds more 
>>> complicated than just doing self.get('Content-Type', '') :)
>>> 
>>> On 26 December 2016 at 05:57, GMail >> > wrote:
>>> Hi! I'm using Django 1.10.2 and Django-Rest-Framework 3.5.3.
>>> I noticed, that HttpRequest.__repr__ method relies on 'Content-Type' header:
>>> 
>>> 
>>> > class HttpResponse(HttpResponseBase):
>>> > ...
>>> >
>>> > def __repr__(self):
>>> > return '<%(cls)s status_code=%(status_code)d, 
>>> > "%(content_type)s">' % {
>>> > 'cls': self.__class__.__name__,
>>> > 'status_code': self.status_code,
>>> > 'content_type': self['Content-Type'],
>>> > }
>>> 
>>> 
>>> And after deleting an object in DRF sends empty response with HTTP204 and 
>>> no 'Content-Type' header. I was trying to log outgoing response and got 
>>> KeyError here.
>>> 
>>> So I have two questions:
>>> 1. Is this intentional? Do all responses in Django have 'Content-Type' 
>>> header and should DRF be aware of it?
>>> 2. Why not use `str.format` here? To avoid errors like this, `dict` 
>>> subclass with `__missing__` method could be used.
>>> 
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Django developers  (Contributions to Django itself)" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to django-developers+unsubscr...@googlegroups.com 
>>> .
>>> To post to this group, send email to django-developers@googlegroups.com 
>>> .
>>> Visit this group at https://groups.google.com/group/django-developers 
>>> .
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-developers/39F85D40-019C-411A-BCA7-402E338EA527%40gmail.com
>>>  
>>> .
>>> For more options, visit https://groups.google.com/d/optout 
>>> .
>>> 
>>> 
>>> 
>>> -- 
>>> Adam
>>> 
>>> -- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "Django developers (Contributions to Django itself)" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to django-developers+unsubscr...@googlegroups.com 
>>> .
>>> To post to this group, send email to django-developers@googlegroups.com 
>>> .
>>> Visit this group at https://groups.google.com/group/django-developers 
>>> .
>>> To view this discussion on 

Re: No 'Content-Type' header in response

2016-12-26 Thread roboslone
So how can I help resolve this? Should I just fork Django on GitHub and make a 
pull-request?

> On 26 Dec 2016, at 15:45, Curtis Maloney  wrote:
> 
> From what I can see in the rfc, it is permitted but not required.
> 
> Only a body in a 204 response is proscribed.
> 
> Any metadata (I.e. headers) are about the resource just accessed... So a 
> Content-Type would, IMHO, be acceptable but not essential.
> 
> 
> 
> On 26 December 2016 9:47:02 PM AEDT, roboslone  wrote:
> Thanks, that was an old setting in Mail.app =/
> 
> I've made a pull-request to DRF: 
> https://github.com/tomchristie/django-rest-framework/pull/4768 
> 
> But it seems to me that fixing it in Django would be more appropriate.
> 
> On the subject of Content-Type header with no response body, seems there's no 
> convention about it, I've found different opinions on the web. The only thing 
> I'm sure about is that putting None in that header is a bad idea.
> 
>> On 26 Dec 2016, at 13:24, Adam Johnson > > wrote:
>> 
>> Hi GMail! (you might want to fix your name used on google groups, I had the 
>> same problem ;) )
>> 
>> This seems to be a legitimate bug in the __repr__ to me - SO informs me that 
>> DRF is correct in not defining a Content-Type for a 204 as it has no body: 
>> https://stackoverflow.com/questions/21029351/what-content-type-should-a-204-no-response-use
>>  
>> 
>> 
>> I created a ticket: https://code.djangoproject.com/ticket/27640 
>>  . If you want to try fix it 
>> there's a great contribution guide at 
>> https://docs.djangoproject.com/en/dev/internals/contributing/ 
>>  . I think 
>> using str.format would be acceptable, but the dict subclass sounds more 
>> complicated than just doing self.get('Content-Type', '') :)
>> 
>> On 26 December 2016 at 05:57, GMail > > wrote:
>> Hi! I'm using Django 1.10.2 and Django-Rest-Framework 3.5.3.
>> I noticed, that HttpRequest.__repr__ method relies on 'Content-Type' header:
>> 
>> 
>> > class HttpResponse(HttpResponseBase):
>> > ...
>> >
>> > def __repr__(self):
>> > return '<%(cls)s status_code=%(status_code)d, "%(content_type)s">' 
>> > % {
>> > 'cls': self.__class__.__name__,
>> > 'status_code': self.status_code,
>> > 'content_type': self['Content-Type'],
>> > }
>> 
>> 
>> And after deleting an object in DRF sends empty response with HTTP204 and no 
>> 'Content-Type' header. I was trying to log outgoing response and got 
>> KeyError here.
>> 
>> So I have two questions:
>> 1. Is this intentional? Do all responses in Django have 'Content-Type' 
>> header and should DRF be aware of it?
>> 2. Why not use `str.format` here? To avoid errors like this, `dict` subclass 
>> with `__missing__` method could be used.
>> 
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django developers  (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-developers+unsubscr...@googlegroups.com 
>> .
>> To post to this group, send email to django-developers@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-developers 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-developers/39F85D40-019C-411A-BCA7-402E338EA527%40gmail.com
>>  
>> .
>> For more options, visit https://groups.google.com/d/optout 
>> .
>> 
>> 
>> 
>> -- 
>> Adam
>> 
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django developers (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-developers+unsubscr...@googlegroups.com 
>> .
>> To post to this group, send email to django-developers@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-developers 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-developers/CAMyDDM39qZj7fV-MvPX%2BtXvSNL9%2B80283Aa5P47uBh3D46Q8BQ%40mail.gmail.com
>>  
>> 

Re: No 'Content-Type' header in response

2016-12-26 Thread Curtis Maloney
>From what I can see in the rfc, it is permitted but not required.

Only a body in a 204 response is proscribed.

Any metadata (I.e. headers) are about the resource just accessed... So a 
Content-Type would, IMHO, be acceptable but not essential.



On 26 December 2016 9:47:02 PM AEDT, roboslone  wrote:
>Thanks, that was an old setting in Mail.app =/
>
>I've made a pull-request to DRF:
>https://github.com/tomchristie/django-rest-framework/pull/4768
>
>But it seems to me that fixing it in Django would be more appropriate.
>
>On the subject of Content-Type header with no response body, seems
>there's no convention about it, I've found different opinions on the
>web. The only thing I'm sure about is that putting None in that header
>is a bad idea.
>
>> On 26 Dec 2016, at 13:24, Adam Johnson  wrote:
>> 
>> Hi GMail! (you might want to fix your name used on google groups, I
>had the same problem ;) )
>> 
>> This seems to be a legitimate bug in the __repr__ to me - SO informs
>me that DRF is correct in not defining a Content-Type for a 204 as it
>has no body:
>https://stackoverflow.com/questions/21029351/what-content-type-should-a-204-no-response-use
>
>> 
>> I created a ticket: https://code.djangoproject.com/ticket/27640
> . If you want to try fix
>it there's a great contribution guide at
>https://docs.djangoproject.com/en/dev/internals/contributing/
> . I
>think using str.format would be acceptable, but the dict subclass
>sounds more complicated than just doing self.get('Content-Type', '') :)
>> 
>> On 26 December 2016 at 05:57, GMail > wrote:
>> Hi! I'm using Django 1.10.2 and Django-Rest-Framework 3.5.3.
>> I noticed, that HttpRequest.__repr__ method relies on 'Content-Type'
>header:
>> 
>> 
>> > class HttpResponse(HttpResponseBase):
>> > ...
>> >
>> > def __repr__(self):
>> > return '<%(cls)s status_code=%(status_code)d,
>"%(content_type)s">' % {
>> > 'cls': self.__class__.__name__,
>> > 'status_code': self.status_code,
>> > 'content_type': self['Content-Type'],
>> > }
>> 
>> 
>> And after deleting an object in DRF sends empty response with HTTP204
>and no 'Content-Type' header. I was trying to log outgoing response and
>got KeyError here.
>> 
>> So I have two questions:
>> 1. Is this intentional? Do all responses in Django have
>'Content-Type' header and should DRF be aware of it?
>> 2. Why not use `str.format` here? To avoid errors like this, `dict`
>subclass with `__missing__` method could be used.
>> 
>> --
>> You received this message because you are subscribed to the Google
>Groups "Django developers  (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it,
>send an email to django-developers+unsubscr...@googlegroups.com
>.
>> To post to this group, send email to
>django-developers@googlegroups.com
>.
>> Visit this group at https://groups.google.com/group/django-developers
>.
>> To view this discussion on the web visit
>https://groups.google.com/d/msgid/django-developers/39F85D40-019C-411A-BCA7-402E338EA527%40gmail.com
>.
>> For more options, visit https://groups.google.com/d/optout
>.
>> 
>> 
>> 
>> -- 
>> Adam
>> 
>> -- 
>> You received this message because you are subscribed to the Google
>Groups "Django developers (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it,
>send an email to django-developers+unsubscr...@googlegroups.com
>.
>> To post to this group, send email to
>django-developers@googlegroups.com
>.
>> Visit this group at https://groups.google.com/group/django-developers
>.
>> To view this discussion on the web visit
>https://groups.google.com/d/msgid/django-developers/CAMyDDM39qZj7fV-MvPX%2BtXvSNL9%2B80283Aa5P47uBh3D46Q8BQ%40mail.gmail.com
>.
>> For more options, visit https://groups.google.com/d/optout
>.
>
>-- 
>You received this message because you are subscribed to the Google
>Groups "Django developers  (Contributions to Django itself)" group.
>To unsubscribe from this group and stop receiving emails from

Re: No 'Content-Type' header in response

2016-12-26 Thread roboslone
Thanks, that was an old setting in Mail.app =/

I've made a pull-request to DRF: 
https://github.com/tomchristie/django-rest-framework/pull/4768 

But it seems to me that fixing it in Django would be more appropriate.

On the subject of Content-Type header with no response body, seems there's no 
convention about it, I've found different opinions on the web. The only thing 
I'm sure about is that putting None in that header is a bad idea.

> On 26 Dec 2016, at 13:24, Adam Johnson  wrote:
> 
> Hi GMail! (you might want to fix your name used on google groups, I had the 
> same problem ;) )
> 
> This seems to be a legitimate bug in the __repr__ to me - SO informs me that 
> DRF is correct in not defining a Content-Type for a 204 as it has no body: 
> https://stackoverflow.com/questions/21029351/what-content-type-should-a-204-no-response-use
>  
> 
> 
> I created a ticket: https://code.djangoproject.com/ticket/27640 
>  . If you want to try fix it 
> there's a great contribution guide at 
> https://docs.djangoproject.com/en/dev/internals/contributing/ 
>  . I think 
> using str.format would be acceptable, but the dict subclass sounds more 
> complicated than just doing self.get('Content-Type', '') :)
> 
> On 26 December 2016 at 05:57, GMail  > wrote:
> Hi! I'm using Django 1.10.2 and Django-Rest-Framework 3.5.3.
> I noticed, that HttpRequest.__repr__ method relies on 'Content-Type' header:
> 
> 
> > class HttpResponse(HttpResponseBase):
> > ...
> >
> > def __repr__(self):
> > return '<%(cls)s status_code=%(status_code)d, "%(content_type)s">' 
> > % {
> > 'cls': self.__class__.__name__,
> > 'status_code': self.status_code,
> > 'content_type': self['Content-Type'],
> > }
> 
> 
> And after deleting an object in DRF sends empty response with HTTP204 and no 
> 'Content-Type' header. I was trying to log outgoing response and got KeyError 
> here.
> 
> So I have two questions:
> 1. Is this intentional? Do all responses in Django have 'Content-Type' header 
> and should DRF be aware of it?
> 2. Why not use `str.format` here? To avoid errors like this, `dict` subclass 
> with `__missing__` method could be used.
> 
> --
> You received this message because you are subscribed to the Google Groups 
> "Django developers  (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-developers+unsubscr...@googlegroups.com 
> .
> To post to this group, send email to django-developers@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/django-developers 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-developers/39F85D40-019C-411A-BCA7-402E338EA527%40gmail.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .
> 
> 
> 
> -- 
> Adam
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-developers+unsubscr...@googlegroups.com 
> .
> To post to this group, send email to django-developers@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/django-developers 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-developers/CAMyDDM39qZj7fV-MvPX%2BtXvSNL9%2B80283Aa5P47uBh3D46Q8BQ%40mail.gmail.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django

Re: No 'Content-Type' header in response

2016-12-26 Thread Adam Johnson
Hi GMail! (you might want to fix your name used on google groups, I had the
same problem ;) )

This seems to be a legitimate bug in the __repr__ to me - SO informs me
that DRF is correct in not defining a Content-Type for a 204 as it has no
body:
https://stackoverflow.com/questions/21029351/what-content-type-should-a-204-no-response-use

I created a ticket: https://code.djangoproject.com/ticket/27640 . If you
want to try fix it there's a great contribution guide at
https://docs.djangoproject.com/en/dev/internals/contributing/ . I think
using str.format would be acceptable, but the dict subclass sounds more
complicated than just doing self.get('Content-Type', '') :)

On 26 December 2016 at 05:57, GMail  wrote:

> Hi! I'm using Django 1.10.2 and Django-Rest-Framework 3.5.3.
> I noticed, that HttpRequest.__repr__ method relies on 'Content-Type'
> header:
>
>
> > class HttpResponse(HttpResponseBase):
> > ...
> >
> > def __repr__(self):
> > return '<%(cls)s status_code=%(status_code)d,
> "%(content_type)s">' % {
> > 'cls': self.__class__.__name__,
> > 'status_code': self.status_code,
> > 'content_type': self['Content-Type'],
> > }
>
>
> And after deleting an object in DRF sends empty response with HTTP204 and
> no 'Content-Type' header. I was trying to log outgoing response and got
> KeyError here.
>
> So I have two questions:
> 1. Is this intentional? Do all responses in Django have 'Content-Type'
> header and should DRF be aware of it?
> 2. Why not use `str.format` here? To avoid errors like this, `dict`
> subclass with `__missing__` method could be used.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers  (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-developers@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-developers.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-developers/39F85D40-019C-411A-BCA7-402E338EA527%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Adam

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAMyDDM39qZj7fV-MvPX%2BtXvSNL9%2B80283Aa5P47uBh3D46Q8BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.