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: | 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 , 18 years ago
comment:2 by , 18 years ago
Triage Stage: | Unreviewed → Design decision needed |
---|
comment:3 by , 17 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
Duplicate of #3362, which has a patch.
comment:4 by , 12 years ago
Easy pickings: | unset |
---|---|
Resolution: | duplicate |
Status: | closed → new |
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 , 12 years ago
Severity: | normal → Normal |
---|
comment:6 by , 12 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
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.
sorry, I've mispelled the email in the initial ticket.