Remove the given parameter completely from the Content-Type header. The header will be re-written in place without the parameter or its value. All values will be quoted as necessary unless requote is False. Optional header specifies an alternative to the Content-Type
(self, param, header='content-type', requote=True)
| 794 | self[header] = ctype |
| 795 | |
| 796 | def del_param(self, param, header='content-type', requote=True): |
| 797 | """Remove the given parameter completely from the Content-Type header. |
| 798 | |
| 799 | The header will be re-written in place without the parameter or its |
| 800 | value. All values will be quoted as necessary unless requote is |
| 801 | False. Optional header specifies an alternative to the Content-Type |
| 802 | header. |
| 803 | """ |
| 804 | if header not in self: |
| 805 | return |
| 806 | new_ctype = '' |
| 807 | for p, v in self.get_params(header=header, unquote=requote): |
| 808 | if p.lower() != param.lower(): |
| 809 | if not new_ctype: |
| 810 | new_ctype = _formatparam(p, v, requote) |
| 811 | else: |
| 812 | new_ctype = SEMISPACE.join([new_ctype, |
| 813 | _formatparam(p, v, requote)]) |
| 814 | if new_ctype != self.get(header): |
| 815 | del self[header] |
| 816 | self[header] = new_ctype |
| 817 | |
| 818 | def set_type(self, type, header='Content-Type', requote=True): |
| 819 | """Set the main type and subtype for the Content-Type header. |