EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  <20242025  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  <20242025 
<== Date ==> <== Thread ==>

Subject: Re: HTTP PUT Request - StreamDevice
From: Zimoch Dirk via Tech-talk <tech-talk at aps.anl.gov>
To: Kyle Hesse <hesse at jlab.org>
Cc: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Mon, 16 Sep 2024 07:44:17 +0000
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.


References:
HTTP PUT Request - StreamDevice Kyle Hesse via Tech-talk
Re: HTTP PUT Request - StreamDevice Zimoch Dirk via Tech-talk
Re: HTTP PUT Request - StreamDevice Zimoch Dirk via Tech-talk
Re: HTTP PUT Request - StreamDevice Kyle Hesse via Tech-talk
Re: HTTP PUT Request - StreamDevice Zimoch Dirk via Tech-talk
Re: HTTP PUT Request - StreamDevice Kyle Hesse via Tech-talk

Navigate by Date:
Prev: Re: Help with rtems nfs mounting Chris Johns via Tech-talk
Next: Initializing lsi or waveform with long string in 3.15.9 Barrett (US), Patrick E via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  <20242025 
Navigate by Thread:
Prev: Re: HTTP PUT Request - StreamDevice Kyle Hesse via Tech-talk
Next: Warning on Linux kernel < 2.6.31 (Re: SoftIoc with Warning: Unable to clear IP_MULTICAST_ALL on Ubunto on WSL) Shuei YAMADA via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  <20242025 
ANJ, 17 Sep 2024 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions ·
· Download · Search · IRMIS · Talk · Documents · Links · Licensing ·