[asterisk-dev] AMI syntax
Mark Michelson
mmichelson at digium.com
Thu Sep 19 12:17:39 CDT 2013
On 09/19/2013 10:31 AM, jg wrote:
> Hi,
>
> I am wondering how rigid the AMI syntax is. Is it strictly
> <key> ': ' <value>'\r\n'
> or is surrounding white space allowed like
> <space>* <key> <space>* ':' <space>* <value> <space>* '\r\n' ?
>
> I have never seen any responses or events with extra space, but
> writing a scanner that does not allow it may be too strict.
>
> jg
When it comes to parsing incoming AMI actions, Asterisk will accept:
<key> ':' <space>+ <value> <CRLF>
If there is arbitrary space before the key, then Asterisk will not
properly match on the key as expected. There must be at least one space
between the colon and the value. If there is trailing space after the
value, then Asterisk will consider that extra space to be part of the
value (though this should maybe be changed?).
When it comes to outgoing AMI events, you should apply the same
treatment. Asterisk will not place leading space before the key.
Asterisk will typically (probably 100% of the time, actually) output
with a single space between the colon and the value, but it couldn't
hurt to allow for any number of spaces just in case.
Mark Michelson
More information about the asterisk-dev
mailing list