Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 51a60eadb4629e1fdff0624783ddb93f3a48d9b3
Ticket: 2b1eaecfae3aab675dab7837db3a6fea5bd7d484
http fails under certain circumstances
User & Date: JKU on 2013-08-13 13:59:00
Changes

  1. assignee changed to: "nobody"
  2. closer changed to: "nobody"
  3. cmimetype changed to: "text/x-fossil-wiki"
  4. comment changed to:
    The http library may call http::Eof twice under certain circumstances, which leads to a "data error" on the second try to remove the encoding.
    
    <verbatim>
    % package require http
    2.8.5
    % proc putargs args {puts $args}
    % trace add execution ::http::Eof enter putargs
    % http::geturl http://johannes13.de:36895/hgolf.tcl
    {Eof ::http::44} enter
    {Eof ::http::44} enter
    data error
    </verbatim>
    
    One possible way is if the server
    
      *  sends the header "Connection: keep-alive"
      *  sends the header "Content-Encoding: gzip"
      *  closes the connection after the request.
    
    Example webserver (I wrote it for code-golf and modified it a bit to match the requirements above):
    
    <verbatim>
    socket -server a 36895
    proc a s\ args {
    set h 200\ OK;set c "\nConnection: keep-alive\nContent-Encoding: gzip\nContent-Type: ";set g 0
    expr {[regexp {GET (\S*)} [gets $s] - 1]?[file isd [set f /home/$1]]?0:[file exi $f]?[set g 1;file ext $f]in{.txt .html}?[append h $c[dict get {.txt text/plain .html text/html} [file ext $f]]]:[append h ${c}application/octet-stream]:[set h 404\ Not\ Found]:[set h 405\ Not\ Supported]}
    puts $s HTTP/1.1\ $h
    if $g {flush $s;  set h [open $f];set cnt [zlib gzip [read $h]];
    puts $s "Content-Length: [string le $cnt]\n"
    flush $s
    fconfigure $s -translation binary;
    puts -nonewline $s $cnt
    close $h}
    close $s}
    </verbatim>
    
  5. foundin changed to: "Tcl 8.6.0 http 2.8.5"
  6. is_private changed to: "0"
  7. login: "JKU"
  8. priority changed to: "5 Medium"
  9. resolution changed to: "None"
  10. severity changed to: "Minor"
  11. status changed to: "Open"
  12. submitter changed to: "JKU"
  13. subsystem changed to: "29. http Package"
  14. title changed to: "http fails under certain circumstances"
  15. type changed to: "Bug"