MenzAgitat Op

Joined: 04 Jul 2006 Posts: 118 Location: France
|
Posted: Thu Apr 07, 2016 9:21 am Post subject: [solved] No data returned when requesting content from https |
|
|
Hello,
I'm trying to make a translator using the Yandex API at https://translate.yandex.net/api/ and I'm encountering some difficulties.
Here is what I am doing :
| Code: | .tcl ::http::register https 443 ::tls::socket
Tcl: 443 ::tls::socket
.tcl ::http::geturl "https://translate.yandex.net/api/v1.5/tr.json/translate?key=MY_API_KEY&text=this%20is%20a%20test&lang=fr&format=plain&options=1" -timeout 10000
Tcl: ::http::6242
.tcl http::status ::http::6242
Tcl: ok
.tcl ::http::data ::http::6242
Tcl:
.tcl array get ::http::6242
Tcl: sock sock8 http {} querylength 0 -queryblocksize 8192 state connecting charset iso8859-1 type text/html -binary 1 url https://translate.yandex.net/api/v1.5/tr.json/translate?key=MY_API_KEY&text=this%20is%20a%20test&lang=fr&format=plain&options=1 -keepalive 0 -timeout 10000 socketinfo translate.yandex.net:443 queryoffset 0 binary 0 -strict 1 totalsize 0 -validate 0 -protocol 1.1 connection close -queryprogress {} -headers {} after after#40937 -blocksize 8192 coding {} status ok body {} currentsize 0 meta {} -type application/x-www-form-urlencoded |
I replaced my own API key by MY_API_KEY in the example, but you can obtain one freely here : https://tech.yandex.com/key/form.xml?service=trnsl
As you can see, geturl returns the "ok" status but I get no data.
Tests have been made using :
Eggdrop v1.6.21 / Tcl 8.5.3 / http package 2.7.5 / tls package 1.50
Any idea would be greatly appreciated.
Edit : Problem solved, adding -tls1 1 to ::tls::socket parameters did the trick.
_________________
My releases: http://www.boulets.oqp.me/tcl/scripts/index.html
My toolbox: http://www.boulets.oqp.me/tcl/routines/index.html
|
|