[Xymon] Multiple http headers

Japheth Cleaver cleaver at terabithia.org
Tue Nov 8 23:28:49 CET 2016


On 11/8/2016 10:01 AM, Patrick Nixon wrote:
> Hey all,
>  I'm attempted to pass two headers along with the http request.   I 
> found httphdr which appears to be what I want to use.
>
> This is the hosts entry as it stands now.
> (two lines
> 0.0.0.0 apiserver # noconn auto https://apiserver/api/status 
> httphdr="X-app-key: 00000000000
> X-app-id: 1111111"
>
> I also tried
> 0.0.0.0 apiserver # noconn auto https://apiserver/api/status 
> httphdr="X-app-key: 00000000000, X-app-id: 1111111"
>
> When I run this from the command line it works as expected
> curl -H "X-app-id: 1111111" -H "X-app-key: 0000000000" 
> https://apiserver/api/status
>
> Suggestions on what to tweak to make this funcitonal?

Unfortunately, the current syntax doesn't really allow for it multiple 
headers properly. This is something that should probably be added, 
though. The string is naively inserted into the HTTP payload followed by 
a \r\n, but otherwise is unchanged.


The problem with the first syntax is two-fold: hosts.cfg is processed 
first getting rid of escaped newlines, so when config options are passed 
in they're expected to be on a single line. The parser is looking for 
the end of the quote and/or the new line itself and stops there, so you 
only get the first part. Modifying that to incorporate the literal, 
alas, would give you "X-app-key: 00000000000\nX-app-id: 1111111" 
(assuming you're on a *nix system), but that's incorrect for headers.

Allowing for multiple httphdr="" would be the cleanest syntax, but I'm 
not actually certain if we ever parse anything like that as it stands 
now, so it may take a little bit of work. Allowing for escaped values in 
quoted strings is another option. It's less clean for this value 
(httphdr="Something\r\nSomethingElse" - yuck) but could have other 
value. It also could cause problems with other options, though, like 
regex's which pass through to further processing. It also means 
re-escaping when doing hosts.cfg file transfers and queries.

A short term hack would be to special case "\r\n" in this field alone 
and substitute the real thing at the moment when we inject the headers, 
but that's... also kind of ugly.


Regards,
-jc



More information about the Xymon mailing list