This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

[solved] No data returned when requesting content from https

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
MenzAgitat
Op
Posts: 118
Joined: Tue Jul 04, 2006 12:35 pm
Location: France
Contact:

[solved] No data returned when requesting content from https

Post by MenzAgitat »

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: Select all

.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.
 
Post Reply