next up previous contents
Next: Example Up: Overview Previous: Aliases through GET   Contents

Parsing information

In a very simple way... watch ;)
Aloha will deliver any verb with a bunch of information, some asked for, and some not, but which will come along: the environment variables (bunch of stuff coming from the user's browser).
Here is an example:

args = {{{}, {{"username", "this is a test"}}, {{"login", "moa"}, {"passwd", "niark"}}}, "SERVER_SOFTWARE", "Aloha Web Server - Version 2.2"},
{"GATEWAY_INTERFACE", "CGI/1.1"}, {"SERVER_PROTOCOLE", "HTTP/1.0"}, {"REQUEST_METHOD", "POST"}, {"SCRIPT_NAME", "submittest"},
{"HTTP_REFERER", "http://127.0.0.1:2222/97/test?login=moa&passwd=niark"}, {"HTTP_USER_AGENT", "Mozilla/4.08 [en] (X11; I; Linux 2.4.20-24.9 i686; Nav)"}, {"SERVER_NAME", "127.0.0.1"}, {"SERVER_PORT", "2222"},
{"HTTP_ACCEPT", "gzip"}, {"HTTP_LANGUAGE", "en"}, {"HTTP_CHARSET", "iso-8859-1,*,utf-8"}, {"CONTENT-TYPE", "multipart/form-data; boundary=--------------20363914401191307546892998980"}, {"CONTENT-LENGTH", "189"}}}

Ok, may be I did not chose the best clearest approach, give me another chance. Let's take out all the blabla and look at the scructure for a moment.

{{{}, {Data from POST}, {Data from GET}}, {{Environment variables}}

So pretty much it gives back a LIST {}, which is composed of of two LISTs inside: {{}, {}}. The first one is for variables that you pass along through GET or POST, and the second one is for environment variables.
The environment variables are generated by $kahuna:get_Env(), which you can modify at your convience (see section 1.7.1).

Now all variables passed come in pairs: variable name, and variable value. In GET, they come under the cover: var=value while in POST, they could come from the HTML file as NAME="var" VALUE="value". So each variable and its value will come as STRING within a LIST: {"username", "this is a test"}. If there are more than one values for one variable name, they are just appended: the first one will be the name, all the other will be the values: {"username", "this is a first test", "and a second one"}.
If you pass more than one variables in GET, you will have two LISTS: {{"login", "moa"}, {"passwd", "niark"}} where on my URL, they appeared like:
http://server:port/97/test?login=moa&passwd=niark

By now I am sure you start getting the picture.

So to summarize:

;args[1] = {{}, {{"username", "this is a test"}}, {{"login", "moa"}, {"passwd", "niark"}}}
;args[2] = "SERVER_SOFTWARE", "Aloha Web Server - Version 2.2"},
{"GATEWAY_INTERFACE", "CGI/1.1"}, {"SERVER_PROTOCOLE", "HTTP/1.0"}, {"REQUEST_METHOD", "POST"}, {"SCRIPT_NAME", "submittest"},
{"HTTP_REFERER", "http://127.0.0.1:2222/97/test?login=moa&passwd=niark"},
{"HTTP_USER_AGENT", "Mozilla/4.08 [en] (X11; I; Linux 2.4.20-24.9 i686; Nav)"}, {"SERVER_NAME", "127.0.0.1"}, {"SERVER_PORT", "2222"},
{"HTTP_ACCEPT", "gzip"}, {"HTTP_LANGUAGE", "en"}, {"HTTP_CHARSET", "iso-8859-1,*,utf-8"}, {"CONTENT-TYPE", "multipart/form-data; boundary=--------------20363914401191307546892998980"}, {"CONTENT-LENGTH", "189"}}

Similarly,

;args[1][2] = {"username", "this is a test"}
;args[2][1] = {"SERVER_SOFTWARE", "Aloha Web Server - Version 2.1"}

Ok, so I'd assume you are now expert. Once you see the global picture, it's pretty simple uh? And of course, at this very moment, I can see your arm raising in the arm, fusing like a rocket:

what is ;args[1][1]??

Aaaarrghhh!!!! :(

Sorry, I forgot... I *think* I added up for the variables passed like:

http://server:port/object?var

which will be used for authentication. But I never tested it yet. Stay tune; but I'm glad you asked that question, it shows me that you are slick and sharp and that I'm not talking to walls here :)

So anyway, as mentioned above, you do not have to pass BOTH GET and POST. Let's look at another more concret example:


next up previous contents
Next: Example Up: Overview Previous: Aliases through GET   Contents
Kr@nX 666 2004-01-04