Posted to tcl by hypnotoad at Tue Oct 08 21:23:18 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. set REPLY [encoding convertto utf-8 $reply_body]
  10. ###
  11. # Return dynamic content
  12. ###
  13. set length [string length $REPLY]
  14. set result {}
  15. if {${length} > 0} {
  16. my reply set Content-Length $length
  17. append result [my reply output] \n
  18. append result $REPLY
  19. } else {
  20. append result [my reply output]
  21. }
  22. chan puts -nonewline $chan $result
  23. catch {chan flush $chan}
  24. my log HttpAccess {}
  25. } err
  26. }