Posted to tcl by aspect at Sun Oct 18 04:03:44 GMT 2015view raw

  1. puts "Tcl: [package require Tcl]"
  2. puts "tls: [package require tls]"
  3. puts "http: [package require http]"
  4. http::register https 443 tls::socket
  5.  
  6. # makes no difference in my env ...
  7. # ::tls::init -tls1 0 -tls1.2 1 -tls1.1 0 -ssl3 0 -ssl2 0
  8.  
  9. proc pdict {d} {
  10. array set {} $d
  11. parray {}
  12. }
  13.  
  14. proc fetch {url} {
  15. puts "Fetching $url ..."
  16. try {
  17. set t [::http::geturl $url]
  18. set l [string length [::http::data $t]]
  19. ::http::cleanup $t
  20. puts "OK! $l bytes"
  21. } on error {e o} {
  22. puts "ERROR: $e"
  23. pdict $o
  24. puts "CHANS: [chan names]"
  25. }
  26. }
  27.  
  28. fetch https://google.com/ ;# this succeeds
  29. fetch https://1337x.to/ ;# this fails
  30. fetch https://google.com/ ;# then a (harmless?) error is emitted here
  31.  
  32. if 0 {
  33. # annotated output: "-:" = stdout; "#!" = stderr
  34.  
  35. -: Tcl: 8.6.4
  36. -: tls: 1.6.7
  37. -: http: 2.8.9
  38.  
  39. -: Fetching https://google.com/ ...
  40. -: OK! 261 bytes
  41.  
  42. -: Fetching https://1337x.to/ ...
  43. -: ERROR: error flushing "sock1d18440": connection reset by peer
  44. -: (-code) = 1
  45. -: (-errorcode) = NONE
  46. -: (-errorinfo) = error flushing "sock1d18440": connection reset by peer
  47. -: while executing
  48. -: "::http::geturl $url"
  49. -: (-errorline) = 4
  50. -: (-errorstack) = INNER {invokeStk1 ::http::geturl https://1337x.to/} CALL {fetch https://1337x.to/}
  51. -: (-level) = 0
  52. -: CHANS: stdin stdout stderr
  53.  
  54. -: Fetching https://google.com/ ...
  55. #! SSL channel "socka20440": error: tlsv1 alert internal error
  56. -: OK! 261 bytes
  57. }
  58.