Re: [Asterisk-java-devel] org.asteriskjava.fastagi.internal.AgiReaderImpl doesn't haven't multiline
Brought to you by:
srt
From: Stefan R. <ste...@re...> - 2006-12-27 22:16:29
|
Hi, AGI (as many Asterisk APIs) is very poorly documented and a "specification" (besides the source) does not exist (at least as far as know). What I thought when implementing the AgiReader was that newlines are forbidden in variable names (in fact you are unable to set them through the dialplan). I played around with the current implementation (Asterisk 1.2.13) and checked the handling of quotes. If we try to support multiline values in variable content by looking for matching quotes before returning, quotes must be correctly escaped by Asterisk as you aready noted. Here are my results: This is the Java code I used: public void service(AgiRequest request, AgiChannel channel) throws AgiException { setVariable("TESTVAR", "ab \" cd"); System.out.println(getVariable("TESTVAR")); } which prints: ab " cd The network dump shows: # ngrep port 4573 interface: eth0 (10.13.0.0/255.255.255.0) filter: (ip or ip6) and ( port 4573 ) (snip) T 10.13.0.57:4573 -> 10.13.0.102:55592 [AP] SET VARIABLE "TESTVAR" "ab \" cd". ## T 10.13.0.102:55592 -> 10.13.0.57:4573 [AP] 200 result=3D1. # T 10.13.0.57:4573 -> 10.13.0.102:55592 [AP] GET VARIABLE "TESTVAR". # T 10.13.0.102:55592 -> 10.13.0.57:4573 [AP] 200 result=3D1 (ab " cd). Until now I have no idea on how to support newlines as matching by quotes seems to be impossible. Additionally I have worries regarding the Manager API. The Manager reponses follow this syntax: key1: value1\n key2: value2\n \n Variables values with newlines would probably cause Asterisk to return an invalid response to a GetVariable action (I am speculating here as I didnt test it actually). Any ideas? =3DStefan Steve Prior wrote: > Stefan Reuter wrote: >=20 >> Hi Steve, >> >> Steve Prior wrote: >> >>> The big thing stopping me from fixing this right now is that I don't = >>> know exactly what the format for a multi-line response to=20 >>> getFullVariable is defined to be. Anyone know what this is? >> >> Can you point me to some documentation regarding Lumenvox so I can hav= e >> a look at what behavior it expects? >> >> =3DStefan >=20 >=20 > I don't have this documentation, but I don't think I'm actually asking = for anything > Lumenvox specific. It's more about how the AGI protocol works. Here's= a bit of > my asterisk log while running the normal pizza demo: >=20 >=20 > -- Executing Set("IAX2/66.225.202.80:4569-4", "TOPPING=3D<item ind= ex=3D0> > <toppinglist> > <item index=3D0> > <ingredient> > onions > </ingredient> >=20 > </item> > <item index=3D1> > <ingredient> > pepperoni > </ingredient> >=20 > </item> >=20 > </toppinglist> >=20 > </item> > ") in new stack >=20 >=20 > So as you can see the demo is setting the value of an asterisk variable= to a > value which spans lines (and happens to be an XML fragment, but I don't= think you care > about that). The problem appears when I try to call getFullVariable() = on a > variable which returns such a multiline value - the current implementat= ion > of AgiImpl only reads the first line which here is "TOPPING=3D<item ind= ex=3D0> > and doesn't follow through and read the rest of the lines up to the fol= lowing > double quotes. Now I'm sure there is some complication in the AGI prot= ocol > as to how to handle escaped quotes (if they are allowed at all). >=20 > So I think the solution is to modify AgiImpl to read the full set of li= nes for a > response and not stop at one - up until it reads the close quote. Then= I > can simply get that multiline string to my java code, interpret the XML= > as I see fit, and should be all set. >=20 > So multiline variable values has been a possibility all along, it's jus= t never > been encountered before now. >=20 > Thanks > Steve >=20 > -----------------------------------------------------------------------= -- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share= your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D= DEVDEV > _______________________________________________ > Asterisk-java-devel mailing list > Ast...@li... > https://lists.sourceforge.net/lists/listinfo/asterisk-java-devel --=20 reuter network consulting Neusser Str. 110 50760 Koeln Germany Telefon: +49 221 1305699-0 Telefax: +49 221 1305699-90 E-Mail: ste...@re... Jabber: ste...@re... |