Opened 18 years ago

Closed 12 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: dev
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 by mihai_preda@…, 18 years ago

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

comment:2 by Simon G. <dev@…>, 18 years ago

Triage Stage: UnreviewedDesign decision needed

comment:3 by James Bennett, 17 years ago

Resolution: duplicate
Status: newclosed

Duplicate of #3362, which has a patch.

comment:4 by yurii.zolotko@…, 12 years ago

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 by anonymous, 12 years ago

Severity: normalNormal

comment:6 by Jacob, 12 years ago

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