## skrypt Tcl uzywajacy prot. HTTP (pakiet http) # # ... package re http # dwa sposoby przekazywania danych w zadaniu HTTP: # 1. zmienne w url-u, met. GET # 2. dane POST za pusta linia, met. POST # # metoda GET set h1 [http::geturl http://localhost:8001/np02/plik1.tcl?x=1234&y=4321] http::ncode $h1 #% 200 http::data $h1 #% {} x=123&y=321 {} 123 # + akurat taka odp zwraca plik1.tcl: # user query content "par x" http::cleanup $h1 # metoda POST !!! set h1 [http::geturl http://localhost:8001/np02/plik1.tcl \ -query "x=12345&y=54321" ] http::ncode $h1 #% 200 http::data $h1 #% {} {} x=12345&y=54321 12345 # ... # uwierzytelnianie http typu "basic" # + opcja -headers {naglowek wartosc ...}; naglowek bez ":" # exec echo -n "qqq:qqq" | openssl enc -base64 #% cXFxOnFxcQ== # + zakodowac "user:password" set h1 [http::geturl http://localhost:8000/np01/plik1.tcl?x=123&y=321] http::ncode $h1 #% 401 http::cleanup $h1 set h1 [http::geturl http://localhost:8000/np01/plik1.tcl?x=123&y=321 \ -headers {Authorization "Basic cXFxOnFxcQ=="} ] http::ncode $h1 #% 200 http::data $h1 #% qqq x=123&y=321 {} 123 http::cleanup $h1 # ...