Wassup all!
I thought I'd do everyone a favour, and in the spirit of 'read the source
Luke'... ;-)
By the way, anyone, please feel free to correct me if I'm wrong anywhere...
it is too early in the morning... and I shouldn't be staring at code...
This is the function that processes GET requests to cgi-bin/sendsms:
[EMAIL PROTECTED]:~/cvs/remote/gateway/gw]$ grep -n smsbox_req_sendsms *.c
smsbox.c:2312:static Octstr *smsbox_req_sendsms(List *args, Octstr *client_ip, int
*status)
smsbox.c:2983: answer = smsbox_req_sendsms(args, ip, &status);
And, this one processes POST requests:
[EMAIL PROTECTED]:~/cvs/remote/gateway/gw]$ grep -n smsbox_sendsms_post *.c
smsbox.c:2421:static Octstr *smsbox_sendsms_post(List *headers, Octstr *body,
smsbox.c:2985: answer = smsbox_sendsms_post(hdrs, body, ip, &status);
(Aside, so that I have nice spacing...)
[EMAIL PROTECTED]:~/cvs/remote/gateway/gw]$ expand --tabs=8 smsbox.c > smsbox.c.8
[EMAIL PROTECTED]:~/cvs/remote/gateway/gw]$ grep -n -C10 smsbox_req_sendsms smsbox.c.8
Gives:
2975- /* sendsms */
2976- if (octstr_compare(url, sendsms_url) == 0)
2977- {
2978- /*
2979- * decide if this is a GET or POST request and let the
2980- * related routine handle the checking
2981- */
2982- if (body == NULL)
2983: answer = smsbox_req_sendsms(args, ip, &status);
2984- else
2985- answer = smsbox_sendsms_post(hdrs, body, ip, &status);
2986- }
Seeing that:
[EMAIL PROTECTED]:~/cvs/remote/gateway/gw]$ grep -n smsbox_sendsms_post *.c
smsbox.c:2421:static Octstr *smsbox_sendsms_post(List *headers, Octstr *body,
smsbox.c:2985: answer = smsbox_sendsms_post(hdrs, body, ip, &status);
Hopefully, we can agree that these are two different functions.
It appears as though this is the function that processes X-Kannel headers:
[EMAIL PROTECTED]:~/cvs/remote/gateway/gw]$ grep -n get_x_kannel_from_headers *.c
smsbox.c:366:static void get_x_kannel_from_headers(List *headers, Octstr **from,
smsbox.c:1009: get_x_kannel_from_headers(reply_headers, &from, &to,
&udh,
smsbox.c:1019: get_x_kannel_from_headers(reply_headers, &from, &to,
&udh,
smsbox.c:1039: get_x_kannel_from_headers(reply_headers, &from, &to,
&udh,
smsbox.c:2454: get_x_kannel_from_headers(headers, &from, &to, &udh,
smsbox.c:2462: get_x_kannel_from_headers(headers, &from, &to, &udh,
Luckily, for this investigation it isn't called from too many
places. Now... I believe we are interested in the lines ~ 2400 (as,
funnily enough, these lines fall under the function 'smsbox_sendsms_post')
because the lines ~1000 appear to implement smsbox outgoing HTTP request
responses, probably for that cool feature we know as a 'service'.
Anyhow, as you can see, the source says that X-Kannel headers are _only_
processed on sendsms POST requests.
It wouldn't be too hard to add X-Kannel header parsing for the
GET requests, but then I would ask,
'Why, my dears? Why? <hands gesticulating, face contorting, pleading voice>'
X-Kannel (POST) headers simply provide
a mechanism for submitting information which, under GET, is encoded
in the QUERY_STRING. If you are happily encoding GET requests already, then
please, encode everything into the QUERY_STRING. If we supported X-Kannel
headers under GET (for some strange reason), how would we decide which
information to use? It would be arbitrary (for the programmer), e.g.
process X-Kannel after the GET variables, and have any duplicate values
overridden. Ewwwh, yucky poo.
Now, for those CGI coders out there, this misunderstanding is similar to
why in CGI scripts, it is advisabled *not* to mix GET variables and POST
stdin application/x-www-form-urlencoded variables. Of course, you can, I'm
nobody's mother, if you have unique variable names, or... as long as you
know which variable (of the same name) to pay attention to... or both, in
some priority... or maybe the GET one on Wednesday... and the POST one on
Saturday, but only when the moon blue and new... and maybe ignore them all
on Christmas, and return a present. ;-P
(N.B. X-Kannel headers are not application/x-www-form-urlencoded content.)
So, in summary, just do POST *with* X-Kannel headers or GET *without*
X-Kannel headers (everything encoded in the QUERY_STRING).
I believe the Kannel userguide alluded to X-Kannel headers for POST
requests anyway.
Cheers all,
Ben.
--
Benjamin Lee
Melbourne, Australia "Always real." http://www.realthought.net/
__________________________________________________________________________
But you who live on dreams, you are better pleased with the sophistical
reasoning and frauds of talkers about great and uncertain matters than
those who speak of certain and natural matters, not of such lofty nature.
-- Leonardo Da Vinci, "The Codex on the Flight of Birds"