HTTP user name / password athentication
(more) Background:
I can send a command to my Rovio robot by entering this in Internet Explorer:
http://192.168.0.194/rev.cgi?Cmd=nav&action=19&LIGHT=1
I can send a command to my Rovio robot by entering this in Internet Explorer:
http://192.168.0.194/rev.cgi?Cmd=nav&action=19&LIGHT=1
A window pops up stating this and asking for a user
name and password:
"The server 192.168.0.194 at Rovio requires a username and password.
Warning: This server is requesting that your username and password be
sent in an insecure manner (basic authentication
without a secure connection)."
I enter the user name and password and the light on
the robot goes on. If I then enter:
the light goes off without it asking for the user
name and password again.
Update and (finally) the
question:
I'm now able to send a command to the Rovio robot server using the following code:
(with-open-stream
(http (comm:open-tcp-stream "192.168.0.194" 80))
(format http "GET /rev.cgi?Cmd=nav&action=19&LIGHT=1 HTTP/1.0~C~C~C~C"
(code-char 13) (code-char 10)
(code-char 13) (code-char 10))
(force-output http)
(write-string "Waiting to reply...")
(loop for ch = (read-char-no-hang http nil :eof)
until ch
do (write-char #\.)
(sleep 0.25)
finally (unless (eq ch :eof)
(unread-char ch http)))
(terpri)
(loop for line = (read-line http nil nil)
while line
do (write-line line)))
However when I send this I get back the following error message:
Waiting to reply....
HTTP/1.0 401 Unauthorized
Date: Fri, 02 Jan 1970 16:51:25 GMT
Server: WYM/1.0
Connection: close
WWW-Authenticate: Basic realm="Rovio"
Content-Type: text/html
<HTML><HEAD><TITLE>401 Unauthorized</TITLE></HEAD>
<BODY><H1>401 Unauthorized</H1>
Your client does not have permission to get URL /rev.cgi from this server.
</BODY></HTML>
I'm now able to send a command to the Rovio robot server using the following code:
(with-open-stream
(http (comm:open-tcp-stream "192.168.0.194" 80))
(format http "GET /rev.cgi?Cmd=nav&action=19&LIGHT=1 HTTP/1.0~C~C~C~C"
(code-char 13) (code-char 10)
(code-char 13) (code-char 10))
(force-output http)
(write-string "Waiting to reply...")
(loop for ch = (read-char-no-hang http nil :eof)
until ch
do (write-char #\.)
(sleep 0.25)
finally (unless (eq ch :eof)
(unread-char ch http)))
(terpri)
(loop for line = (read-line http nil nil)
while line
do (write-line line)))
However when I send this I get back the following error message:
Waiting to reply....
HTTP/1.0 401 Unauthorized
Date: Fri, 02 Jan 1970 16:51:25 GMT
Server: WYM/1.0
Connection: close
WWW-Authenticate: Basic realm="Rovio"
Content-Type: text/html
<HTML><HEAD><TITLE>401 Unauthorized</TITLE></HEAD>
<BODY><H1>401 Unauthorized</H1>
Your client does not have permission to get URL /rev.cgi from this server.
</BODY></HTML>
The Rovio server apparently needs user name / password authentication. If, for example, the user name is admin and the password is pass123, then how do I send that? It seems like it should be simple and I'm just missing it....
And again thank you all for your help thus far.......
Bruce.