Hi Kyle,
No, currently there is no string length function in StreamDevice. Even if I could implement one using the e.g. checksum support, the result would be available only after outputting the content, not before.
If your hostname does not have a constant length, which would allow to use a constant Content-Length value, you may store your hostname in an lso record instead of a stringout record. The lso record has a field LEN which contains the string length. However,
you would need to add 4 to LEN for the quotes and the terminator. That makes stuff a bit complicated. You would need a calc record to read LEN and add 4 and only then have another record (lso or stringout) to read the string from the first one via DOL and
pass it to StreamDevice. Only this way, the calc record can calculate the final length, before StreamDevice is called.
BTW: I would not use "%*s" to read the (any) reply but instead something like "HTTP%*s 200 %*s" to ensure a success reply code 200.
Dirk
On 13 Sep 2024, at 16:38, Kyle Hesse <hesse at jlab.org> wrote:
Hi Dirk,
I was able to get it working. Thank you for all of your suggestions. Adding additional header information ended up being the solution.
out 'PUT /io/net/hostname/value.json HTTP/1.1\r\nHost: http://129.57.203.137/io/net/hostname/value.json\r\nContent-Type:application/json\r\nContent-Length:
16\r\n\r\n"injivcont1"';
in '%*s';
Omitting content length would result in the hostname not being set.
Any recommendations on how can I dynamically calculate the Content-Length header value for variable-length payloads in StreamDevice for PUT requests?
Appreciate your help,
Kyle
From: Zimoch Dirk <dirk.zimoch at psi.ch>
Sent: Thursday, September 12, 2024 9:18 AM
To: Kyle Hesse <hesse at jlab.org>; tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: [EXTERNAL] Re: HTTP PUT Request - StreamDevice
On Thu, 2024-09-12 at 12:31 +0000, Kyle Hesse wrote:
> I am getting a response of HTTP/1.1 200 OK
If you are getting a response, you should add a matching 'in' command to your
protocol. And then you may not need to disconnect. Still use the http option in
drvAsynIPPortConfigure.
|