From: Thinus P. <th...@er...> - 2005-09-26 09:36:32
|
Hi there We're sending an http request to yaws. See (1). The request contains a string called ussdString. This string is a uuencoded string ussdString="*116*111*AAEGAGQAABEzAABgNIUgAABRdNAABYcAAAAAAAAAgQ6+8zh0D9iBDr7zOHQP2A==1#" Yaws captures this data via script (2). In our logs we get the string as: ussdString=\"*116*111*AAEGAGQAABEzAABgNIUgAABWEtAABYcAAAAAAAAAgQ6<space>8zh0D9iBDr7zOHQP2A==1#\" What's happing is that yaws is dropping the '+' character from our string and inserting a space (verified as ascii code 32 (decimal)) in its place. The tcpdump confirms that the message is sent correctly to yaws. After getting the data from the http request in yaws we get this character replacement. Is this a bug in yaws, or is the + character something special? Or is the problem that we just can't write a proper yaws script ;) The only strings that gets mangled are those containing a + character somewhere. Any ideas? Cheers Thinus ***************************************************** (1) tcpdump of the http request. Hypertext Transfer Protocol Connection: keep-alive\r\n Host: 172.16.100.105:8080\r\n User-Agent: com.truteq.net.http.Connection\r\n Content-type: text/xml\r\n Accept: text/xml\r\n Content-length: 146\r\n \r\n Line-based text data: text/xml <ussdreq tid="999999" reqType="1" msisdn="27842202223" ussdString="*116*111*AAEGAGQAABEzAABgNIUgAABRdNAABYcAAAAAAAAAgQ6+8zh0D9iBDr7zOHQP2A==1#" /> Hypertext Transfer Protocol \r\n ****************************************************** ****************************************************** (2) Script to capture data in yaws <erl> out(Args) -> GetValue = fun(Data, What) -> Pos = string:str(Data, What), Ret1 = string:substr(Data, Pos+length(What)+2, length(Data)-Pos), Pos2 = string:chr(Ret1, 34), string:substr(Ret1,1,Pos2-1) end, {http_request, HttpRequest, Doc, Version} = Args#arg.req, case HttpRequest of 'POST' -> [{UssdReq, PostData}] = yaws_api:parse_post(Args); 'GET' -> PostData = yaws_api:parse_query(Args) end, Tid = string:substr(PostData, 2, 7), error_logger:info_msg("~nPostData = ~p~n",[PostData]), %% Extract required data Msisdn = GetValue(PostData, "msisdn"), ReqType = GetValue(PostData, "reqType"), SubType = GetValue(PostData, "subType"), UssdString = GetValue(PostData, "ussdString"), UssdStringBin = list_to_binary(UssdString), %% Required variables by prod system. error_logger:info_msg("~nUssdString = ~p~nUssdString Binary: ~p~n", [UssdString, UssdStringBin]), *snip* ***************************************************** -- Thinus Pollard Mobile: +27 72 075 2751 |