On 2016/12/7 19:15, Cyril Bonté wrote:
> Hi,
>
> On 07/12/2016 21:40, Patrick Hemmer wrote:
>> How do you use a comma inside an argument to a sample fetcher or
>> converter?
>> For example, the sample fetch str, if I try to do `str(foo,bar)` I get
>> the error
>>
>>     fetch method 'str' : end of arguments expected at position 2, but
>> got ',bar'
>>
>> All variations such as `str('foo,bar')`, `str(foo\,bar)`, etc, result in
>> the same error.
>
> Commas are not supported in converters and sample fetches.
> There may be several workaround but without any context, it's
> difficult to provide one.
>
> For example, you can provide an "urlencoded" string and use url_dec as
> a converter :
>   http-response add-header X-test %[str("foo%2Cbar"),url_dec]
>
The use case is that I have the DeviceAtlas library setting a variable.
But if there is no UserAgent header, the variable is unset. In this case
I want to set it to a default value with the same format, just empty
fields (e.g. ",,,," or "-,-,-,-").
The url_dec trick seems sufficient to accomplish this. A little hackish,
but it works.
Thanks

-Patrick

Reply via email to