Code

Opened 7 years ago

Closed 14 months 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

Attachments (0)

Change History (6)

comment:1 Changed 7 years ago by mihai_preda@…

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

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

  • Triage Stage changed from Unreviewed to Design decision needed

comment:3 Changed 7 years ago by ubernostrum

  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #3362, which has a patch.

comment:4 Changed 14 months ago by yurii.zolotko@…

  • Easy pickings unset
  • Resolution duplicate deleted
  • Status changed from closed to 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 Changed 14 months ago by anonymous

  • Severity changed from normal to Normal

comment:6 Changed 14 months ago by jacob

  • Resolution set to wontfix
  • Status changed from new to 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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.