dear all,
I'm new to this forum and Lisp also, I would like to send greetings to all!
I have a question about configuring header and parameters send in post-url.
when sending (post-url "http://ip.addr/cli/cgi-bin/exe.pl"
"param1=v1¶m2=v2¶m3=v3" "text/plain" 5000 "Content-Length: 50rnAuthorization: Basic encripted-user-psswdrnrn" )
in wireshark it looks very strange:
first packet:
POST /cli/cgi-bin/exe.pl HTTP/1.1rn
Request Method: POST
Request URI: /cli/cgi-bin/exe.pl
Request Version: HTTP/1.1
second:
Hypertext Transfer Protocol
Host: 10.243.117.12rn
Content-Length: 50
Authorization: Basic encrypted-user-psswdrn
rn
Data (50 bytes)
0000 43 6f 6e 6e 65 63 74 69 6f 6e 3a 20 63 6c 6f 73 Connection: clos
0010 65 0d 0a 43 6f 6e 74 65 6e 74 2d 74 79 70 65 3a e..Content-type:
0020 20 0d 0a 43 6f 6e 74 65 6e 74 2d 6c 65 6e 67 74 ..Content-lengt
0030 68 3a h:
Data: 436F6E6E656374696F6E3A20636C6F73650D0A436F6E7465...
Hypertext Transfer Protocol
Data (119 bytes)
0000 20 31 31 31 0d 0a 0d 0a 6e 65 5f 6e 61 6d 65 3d 111....ne_name=
0010 6d 73 63 31 26 74 61 73 6b 5f 74 79 70 65 3d 54 msc1&task_type=T
...
0060 65 3d 73 74 61 74 73 73 70 26 6d 65 74 68 6f 64 e=statssp&method
0070 3d 69 6e 73 69 64 65 =inside
Data: 203131310D0A0D0A6E655F6E616D653D6D73633126746173...
and there is response from server something like wrong user authorisation or similar...
If I omit in header part Content-Length, then server return error that content length is missing.
I would like to get something like this:
Hypertext Transfer Protocol
POST http://10.243.117.12/cli/cgi-bin/exe.pl HTTP/1.1rn
Request Method: POST
Request URI: http://10.243.117.12/cli/cgi-bin/exe.pl
Request Version: HTTP/1.1
Host: 10.243.117.12rn
Accept-Encoding: identityrn
Content-Length: 111
Authorization: Basic cmdvcmVuYzo3R2VsaXB0ZXI3rn
rn
folowed with:
Hypertext Transfer Protocol
Data (111 bytes)
0000 6e 65 5f 6e 61 6d 65 3d 4d 53 43 31 26 74 61 73 ne_name=MSC1&tas
0010 6b 5f 74 79 70 65 3d 54 41 53 4b 26 75 67 5f 6e k_type=TASK&ug_n
...
0060 70 26 6d 65 74 68 6f 64 3d 69 6e 73 69 64 65 p&method=inside
Data: 6E655F6E616D653D4D534331267461736B5F747970653D54...
and after that is correct answer from server.
in python this can be done with request("POST", "http://ip.addr/cli/cgi-bin/exe.pl", params, headers)
describing params and headers as necessary.
Is it possible to get something like this with post-url?
Robert
This is how basic authorization is done for Twitter:
http://www.newlisp.org/syntax.cgi?code/twitter.txt
also referenced from here:
http://www.newlisp.org/index.cgi?Tips_and_Tricks
basically you have to Base 64 encode the authorization yourself:
(set 'auth (append "Authorization: Basic " (base64-enc "john:secret") "rn"))
(get-url the-url 5000 auth)
ps: welcome to newLISP
Thanks Lutz,
Actually, user and psswd encription was not problem. But after Your message, I looked again in my header in post-url and found if remove second pair of rn, than post-url works as expected!!!
the working method is now:
(post-url "http://ip.addr/cli/cgi-bin/exe.pl"
"ne_name=msc1&task_type=TASK&ug_name=rgorenc&NEInputMethod=ViaNEName&Dang_Task=ON&taskname=statssp&method=inside" "" 10000 "Authorization: Basic encripted user-psswdrn" ) !!
thanks again,
Robert
Hi Robert, I'm also from Croatia, Zagreb. Welcome.