Posted to tcl by hypnotoad at Tue Oct 08 22:05:50 GMT 2019view raw

  1. method DoOutput {} {
  2. my variable reply_body chan
  3. if {$chan eq {}} return
  4. catch {
  5. # Causing random issues. Technically a socket is always open for read and write
  6. # anyway
  7. #my wait writable $chan
  8. chan configure $chan -encoding utf-8 -translation {auto crlf}
  9. ###
  10. # Return dynamic content
  11. ###
  12. set length [string length $reply_body]
  13. if {${length} > 0} {
  14. # Causing issues with Safari. When transmitting UTF-8 encoded data there seems
  15. # to be a disagreement about the actual length, and text files are being truncated
  16. #my reply set Content-Length $length
  17. chan puts $chan [my reply output]
  18. chan configure $chan -encoding utf-8 -translation binary
  19. chan puts $chan [encoding convertto utf-8 $reply_body]
  20. } else {
  21. chan puts $chan [my reply output]
  22. }
  23. catch {chan flush $chan}
  24. my log HttpAccess {}
  25. }
  26. }