Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 09db90cdff543f59d26433c1c4ca625be69879a4
Ticket: 838e99a76dd54f1961b8b5c4bdb3da114bf5b6f8
treat application/xml as text
User & Date: gahr on 2016-09-24 19:00:46
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/plain"
  4. comment changed to:
    The http package converts the body of the response to the charset specified in the response headers only if content-type matches text*. This patch proposes to treat application/xml in the same way. The rationale is that xml is encoded in utf-8 by default and carries human readable information.
    Currently, anybody receiving */xml should decode the stream himself, as suggested in [1733261fffffffffffff]. I find this counterintuitive.
    
    A real-world use case for this is WebDAV, which has deprecated the use of text/xml in favour of application/xml, see rfc 4918 ยง8.2 [http://www.webdav.org/specs/rfc4918.html#rfc.section.8.2]
    
    I propose the following patch.
    
    Index: library/http/http.tcl
    ==================================================================
    --- library/http/http.tcl
    +++ library/http/http.tcl
    @@ -1045,11 +1045,15 @@
     
                # We have to use binary translation to count bytes properly.
                fconfigure $sock -translation binary
     
                if {
    -               $state(-binary) || ![string match -nocase text* $state(type)]
    +               $state(-binary) ||
    +               (
    +                   ![string match -nocase text* $state(type)] &&
    +                   ![string match -nocase application/xml* $state(type)]
    +               )
                } {
                    # Turn off conversions for non-text data
                    set state(binary) 1
                }
                if {[info exists state(-channel)]} {
    
  5. foundin changed to: "8.6.6"
  6. is_private changed to: "0"
  7. login: "gahr"
  8. priority changed to: "5 Medium"
  9. private_contact changed to: "438e59f1f1c891b29d2528ed82d1e629cecc6336"
  10. resolution changed to: "None"
  11. severity changed to: "Minor"
  12. status changed to: "Open"
  13. submitter changed to: "gahr"
  14. subsystem changed to: "29. http Package"
  15. title changed to: "treat application/xml as text"
  16. type changed to: "Bug"