Opened 10 years ago

Closed 4 years ago

#3208 closed enhancement (wontfix)

allow to generate a 'no-content' HTTP response (a response with no body)

Reported by: mihai.preda@… Owned by: nobody
Component: Core (Other) Version: master
Severity: Normal Keywords: HttpResponse
Cc: Triage Stage: Design decision needed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I'd need a way to generate a 'no-content' HTTP response, i.e. a response without any of these headers:

Content-Length:
Content-Type:
Transfer-Encoding: chunked
etc.

I think a 'no-content' is different from a 'zero-length' content (HttpResponse() constructs a zero-length content).
I tried using HttpResponse(None) but it doesn't seem to work.

An example of an HTTP response with no content (taken from the MIDP 2.0 OTA Specification):

HTTP/1.1 200 OK
Server: CoolServer/1.3.12

Change History (6)

comment:1 Changed 10 years ago by mihai_preda@…

sorry, I've mispelled the email in the initial ticket.

comment:2 Changed 10 years ago by Simon G. <dev@…>

Triage Stage: UnreviewedDesign decision needed

comment:3 Changed 9 years ago by James Bennett

Resolution: duplicate
Status: newclosed

Duplicate of #3362, which has a patch.

comment:4 Changed 4 years ago by yurii.zolotko@…

Easy pickings: unset
Resolution: duplicate
Status: closednew
UI/UX: unset

#3362 doesn't solve the problem as it can't be done with existing HttpResponse class.
There is still no way to send a response without Content-Type header with Django except this:

    response = HttpResponse(open(unknown_type_file).read())
    del response['Content-Type']

which is very ugly.
According to http://www.w3.org/Protocols/rfc2616/rfc2616-sec7.html Content-Type header is not mandatory and can be omitted to make client guess file type, but it can't be done with Django as setting content_type to None sets it to DEFAULT_CONTENT_TYPE and not really None.

comment:5 Changed 4 years ago by anonymous

Severity: normalNormal

comment:6 Changed 4 years ago by Jacob

Resolution: wontfix
Status: newclosed

You can do this in your own code with an HttpResponse subclass, and it's enough of an esoteric need that Django doesn't need it in core.

Note: See TracTickets for help on using tickets.
Back to Top