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 <2024> 2025 | 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 <2024> 2025 |
<== Date ==> | <== Thread ==> |
---|
Subject: | Re: HTTP PUT Request - StreamDevice |
From: | Kyle Hesse via Tech-talk <tech-talk at aps.anl.gov> |
To: | Zimoch Dirk <dirk.zimoch at psi.ch>, "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov> |
Date: | Thu, 12 Sep 2024 12:31:54 +0000 |
Hi Dirk,
Thank you for your response. I tried both of your suggested methods of
set_host{
out 'PUT /io/net/hostname/value.json HTTP/1.1\r\n\r\n"New-Hostname"';
}
and
OutTerminator = CR LF CR LF;
set_host{ out 'PUT /io/net/hostname/value.json HTTP/1.1';
out '"New-Hostname"';}
I am getting a response of HTTP/1.1 200 OK, however the hostname will not change. I also tried to add in some of the other header lines but had the same result.
curl -X PUT -d '"New-Hostname"'
http://129.57.203.137/io/net/hostname/value.json
When I send the previously mentioned requests I noticed in the console the quotes are escaped:
Command:
set_host{ out 'PUT /io/net/hostname/value.json HTTP/1.1\r\n\r\n"New-Hostname"'; }
Console:
asynSetTraceMask("fx4",-1,0x9)
asynSetTraceIOMask("fx4",-1,0x2)
2024/09/11 16:02:41.166 129.57.203.137:80 HTTP write 57
PUT io/net/hostname/value.json HTTP/1.1\r\n\r\n\"New-Hostname\"
If I send a curl command with escaped quotes, the name will not change:
curl -X PUT -d '\"New-Hostname\"'
http://129.57.203.137/io/net/hostname/value.json
Any suggestions on the way the quotes are escaped in StreamDevice?
Thanks,
Kyle
From: Zimoch Dirk <dirk.zimoch at psi.ch>
Sent: Wednesday, September 11, 2024 10:51 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 Hello Kyle,
For testing, I have started a fake server with: ncat -l -p 8080 And have sent the command to it: curl -X PUT -d '"New-Hostname"' \ https://urldefense.proofpoint.com/v2/url?u=http-3A__fakeserver-3A8080_ioc_net_hostname_value.json&d=DwIGaQ&c=CJqEzB1piLOyyvZjb8YUQw&r=XoO1MAWp671dzq4GtQTw9Q&m=pruKbDwo_Ww12xZBNKqD_nl0qd9_KdK7lo963LHk6QsNWd0CuqhdAsaMbOecVx3N&s=rdFe2srdAMqV1w77G326beUJgCVs9s0rdRZjRtfs5R8&e= What I see in ncat is: PUT /ioc/net/hostname/value.json HTTP/1.1 Host: fakeserver:8080 User-Agent: curl/7.61.1 Accept: */* Content-Length: 14 Content-Type: application/x-www-form-urlencoded "New-Hostname"[no newline!] I guess some lines may be optional, but one thing is important: There is an empty line between header and content. Be aware that your OutTerminator is only added at the end or out commands (where curl did not bother to add any terminator). Thus I suggest you either add the empty line manually: set_host{ out 'PUT /io/net/hostname/value.json HTTP/1.1\r\n\r\n"New-Hostname"'; } Or alternatively use 2 out commands, each will be terminated with CR LF CR LF. set_host{ out 'PUT /io/net/hostname/value.json HTTP/1.1'; out '"New-Hostname"';} If that is still not sufficient, try to add some of the other header lines, but have an empty line only directly before the content. Dirk On Wed, 2024-09-11 at 14:26 +0000, Zimoch Dirk via Tech-talk wrote: > Hi Kyle, > > I will have a look... > > Dirk > > On Wed, 2024-09-11 at 14:19 +0000, Kyle Hesse via Tech-talk wrote: > > Hello, > > > > I'm working with a Pyramid FX4 Device. I'd like to use HTTP requests to communicate using StreamDevice. I'm having success using GETs, however I'm running into issues with the PUTs. > > > > The programmer manual states to do the following: > > > > PUT /io/net/hostname.json HTTP/1.1 > > > > "New-Hostname" > > > > Below I've listed my configuration as well as examples for the GET and PUT requests for getting and setting the hostname. > > > > Any help to properly form the HTTP PUT request would be greatly appreciated. > > > > Thanks, > > > > Kyle > > > > > > > > Configuration: > > > > drvAsynIPPortConfigure("fx4", "129.57.203.137:80 HTTP", 0, 0, 0) > > > > OutTerminator = CR LF CR LF; > > > > PUT Request Example (Unsuccessful): > > > > set_host{ > > out 'PUT /io/net/hostname/value.json HTTP/1.1 "New-Hostname"'; > > } > > > > Get Request (Successful): > > > > hostname { > > out "GET /io/net/hostname/value.json HTTP/1.1"; > > in "%*182c%[_a-zA-Z0-9]%*2c"; > > } > > > > > > > > PS > > > > I am able to use curl from command line to successfully set the hostname. > > > > curl -X PUT -d '"New-Hostname"' https://urldefense.proofpoint.com/v2/url?u=https-3A__urldefense.us_v3_-5F-5Fhttp-3A__129.57.203.137_io_net_hostname_value.json-5F-5F-3B-21-21G-5FuCfscf7eWS-21f01ayFSJNsXqAAqGmOKGPXH4SuSPR-5F8UAlf8IXiWd-2DJuQtDWoFGjoDqT-2DFV3qjx0n8nkLhDvsD1Dx35nhsUmiKf7Ug-24&d=DwIGaQ&c=CJqEzB1piLOyyvZjb8YUQw&r=XoO1MAWp671dzq4GtQTw9Q&m=pruKbDwo_Ww12xZBNKqD_nl0qd9_KdK7lo963LHk6QsNWd0CuqhdAsaMbOecVx3N&s=1IQyXgaS5UUSfCyByWhQ6eRwXFXEBDKfGSpg_q4skjA&e= > > > > |