[Xymon] Multiple http headers
Patrick Nixon
pnixon at gmail.com
Wed Nov 9 21:35:09 CET 2016
Thanks for the reply. Going to script something for now, but will keep an
eye out for updates
On Nov 8, 2016 5:29 PM, "Japheth Cleaver" <cleaver at terabithia.org> wrote:
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
_______________________________________________
Xymon mailing list
Xymon at xymon.com
http://lists.xymon.com/mailman/listinfo/xymon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20161109/91bb08be/attachment.html>
More information about the Xymon
mailing list