obtener url usando el método de publicación http en tcl 8.0

I'm trying to get some urls using post method in tcl 8.0.

it doesn't print any output.

here is chunk of my code.

foreach sKey [array names aQuery] {                                        
    set sValue $aQuery($sKey)                                              
    append sQueryString "[::http::formatQuery $sKey $sValue]&"                                  
}                                                                          

set sQueryString [string trim $sQueryString "&"]                           

set sToken [::http::geturl $sUrl -query $sQueryString -channel stdout] 

::http::wait $sToken                                                   

upvar #0 $sToken state                                                     

foreach sKey [array names state] {                                         
    puts "$sKey $state($sKey)"                                             
}      

preguntado el 28 de agosto de 12 a las 09:08

1 Respuestas

Upgrade already. Why the heck are you using a version that was released in the last millenium.

The http::formatQuery procedure takes one or more key value pairs as arguments so that part would be better rendered as below. If in doubt its probably better to avoid using the -channel option and check for the status yourself. So something like:

set query [eval ::http::formatQuery [array get aQuery]]
set tok [http::geturl $sUrl -query $query -timeout 10000]
http::wait $tok
if {![string compare [http::status] "ok"]} {
    puts [http::data $tok]
} else {
    puts stderr [http::error $tok]
}
http::cleanup $tok

Note that in more recent versions of tcl you could have used [http::status] eq "ok" or [string equal [http::status] "ok"]. Don't forget to cleanup the http token. If you are doing this in a GUI program, use the -command option and do all the work in the callback so you don't freeze the UI while doing the http::wait.

Respondido 28 ago 12, 12:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.