Hi,
Sorry, I forget to remove the old url assignment from http.c when I created
the patch which leaves the MO logging issue unresolved. Here is the modified
and tested patch :)
Regards,
Bassam
On Mon, Oct 10, 2011 at 2:55 AM, Bassam Al-Sarori <[email protected]>wrote:
> Here is the patch :)
>
>
> On Mon, Oct 10, 2011 at 2:54 AM, Bassam Al-Sarori <[email protected]>wrote:
>
>> Hi all,
>>
>> I am new to this mailing list but have been using Kannel for a long time.
>>
>> I want to share a patch which I hope to be useful.
>>
>> The patch solves two issues which I faced with http smsc (generic)
>>
>> 1) URL Parameters of an MO message request are not logged. Only the base
>> URL gets logged, for example,
>> 2011-10-10 00:35:06 [2930] [7] DEBUG: HTTP[httpsmsc]: Got request `/send'
>>
>> Which makes it hard for debugging
>>
>> So, I made some changes so that the full URL and parameters are logged
>>
>> 2011-10-10 00:35:06 [2930] [7] DEBUG: HTTP[httpsmsc]: Got request
>> `/send?from=13123&to=6774638981&text=hi&coding=0&udh='
>>
>> 2) Incorrect success reply for failed MOs. SMSC assumes that the only case
>> of failure is when bb_smscconn_receive returns -1, which is not correct
>> (bb_smscconn_receive never returns -1). So, I changed it to only assume
>> success in case of SMSCCONN_SUCCESS or SMSCCONN_QUEUED is returned.
>>
>> Please note that I am not an experienced C programmer. So, if you find any
>> stupid mistakes let me know. Thanks!
>>
>>
>> Regards,
>> Bassam
>>
>>
>
Index: gw/smsc/smsc_http.c
===================================================================
--- gw/smsc/smsc_http.c (revision 4935)
+++ gw/smsc/smsc_http.c (working copy)
@@ -287,8 +287,8 @@
/* XXX if conn->is_stopped, do not receive new messages.. */
- client = http_accept_request(conndata->port, &ip, &url,
- &headers, &body, &cgivars);
+ client = http_accept_request_real(conndata->port, &ip, &url,
+ &headers, &body, &cgivars,1);
if (client == NULL)
break;
@@ -1810,13 +1810,13 @@
Msg *resp = msg_duplicate(dlrmsg);
ret = bb_smscconn_receive(conn, dlrmsg);
- if (ret == -1) {
- retmsg = octstr_create("Not accepted");
- retstatus = fm->status_error;
- } else {
- retmsg = urltrans_fill_escape_codes(fm->message_sent, resp);
- retstatus = fm->status_sent;
- }
+ if (ret == SMSCCONN_SUCCESS || ret == SMSCCONN_QUEUED){
+ retmsg = urltrans_fill_escape_codes(fm->message_sent, resp);
+ retstatus = fm->status_sent;
+ }else{
+ retmsg = octstr_create("Not accepted");
+ retstatus = fm->status_error;
+ }
msg_destroy(resp);
} else {
error(0,"HTTP[%s]: Got DLR but could not find message or was not interested "
@@ -1901,12 +1901,12 @@
msg->sms.meta_data = octstr_duplicate(meta_data);
Msg *resp = msg_duplicate(msg);
ret = bb_smscconn_receive(conn, msg);
- if (ret == -1) {
+ if (ret == SMSCCONN_SUCCESS || ret == SMSCCONN_QUEUED){
+ retmsg = urltrans_fill_escape_codes(fm->message_sent, resp);
+ retstatus = fm->status_sent;
+ }else{
retmsg = octstr_create("Not accepted");
retstatus = fm->status_error;
- } else {
- retmsg = urltrans_fill_escape_codes(fm->message_sent, resp);
- retstatus = fm->status_sent;
}
msg_destroy(resp);
}
Index: gwlib/http.c
===================================================================
--- gwlib/http.c (revision 4935)
+++ gwlib/http.c (working copy)
@@ -2557,9 +2557,9 @@
}
-HTTPClient *http_accept_request(int port, Octstr **client_ip, Octstr **url,
+HTTPClient *http_accept_request_real(int port, Octstr **client_ip, Octstr **url,
List **headers, Octstr **body,
- List **cgivars)
+ List **cgivars, int keep_url)
{
HTTPClient *client;
@@ -2578,7 +2578,12 @@
} while(client == NULL);
*client_ip = octstr_duplicate(client->ip);
+
+ if(keep_url)
+ *url = octstr_duplicate(client->url);//duplicate otherwise parse_cgivars will eat params
+ else
*url = client->url;
+
*headers = client->request->headers;
*body = client->request->body;
*cgivars = parse_cgivars(client->url);
Index: gwlib/http.h
===================================================================
--- gwlib/http.h (revision 4935)
+++ gwlib/http.h (working copy)
@@ -430,10 +430,15 @@
* many threads to be fast. The HTTP user should use a single thread,
* unless requests can block.
*/
-HTTPClient *http_accept_request(int port, Octstr **client_ip,
+HTTPClient *http_accept_request_real(int port, Octstr **client_ip,
Octstr **url, List **headers, Octstr **body,
- List **cgivars);
+ List **cgivars, int keep_url);
+/* always eats URL params, bb and other boxes use it while SMSCs should
+ use the real one */
+#define http_accept_request(port,client_ip, url, headers, body, cgivars) \
+ http_accept_request_real(port,client_ip, url, headers, body, cgivars, 0)
+
/*
* Send a reply to a previously accepted request. The caller is responsible