18258, "hokiegeek2", "cURL module does not support libcurl curl_slist_append", "2021-08-19T17:55:26Z"
Summary of Problem
The Curl module does not support curl_slist_append, which is needed to build up a list of header elements. In addition, the setopt call fails for setting the slist.
Steps to Reproduce
# Compile error for slist.append
var args = new slist();
args.append("Accept: application/json");
args.append("Content-Type: application/json-patch+json");
# Results in
$CHPL_HOME/modules/packages/Curl.chpl:257: In method 'append':
$CHPL_HOME/modules/packages/Curl.chpl:260: error: unresolved call 'curl_slist_append(c_ptr(curl_slist), c_string)'
$CHPL_HOME/modules/packages/Curl.chpl:260: note: because no functions named curl_slist_append found in scope
An curl_slist_append extern declaration is needed to fix this compile-time error. In addition, as @cassella pointed out, the curl_slist_free_all() function also needs to be added as an extern declaration.
With the help of @cassella and @e-kayrakli I was able to add both of these extern declarations which fixed the above compilation error. Once I got past that one, I encountered this compilation error, which @lydia-duncan helped me fix:
var args = new Curl.slist();
args.append("Accept: application/json");
args.append("Content-Type: application/json-patch+json");
Curl.setopt(urlwriter, CURLOPT_HTTPHEADER, args);
# Curl.setopt on the args slist caused the folllowing compiletion error
$CHPL_HOME/modules/packages/Curl.chpl:151: In function 'setopt':
$CHPL_HOME/modules/packages/Curl.chpl:156: error: unresolved call 'type slist.home'
$CHPL_HOME/modules/packages/Curl.chpl:242: note: this candidate did not match: slist.home
$CHPL_HOME/modules/packages/Curl.chpl:156: note: because method call receiver is a type
$CHPL_HOME/modules/packages/Curl.chpl:242: note: but is passed to non-type formal 'ref this: slist'
$CHPL_HOME/modules/packages/Curl.chpl:156: note: other candidates are:
$CHPL_HOME/modules/standard/IO.chpl:1395: note: file.home
$CHPL_HOME/modules/standard/IO.chpl:1932: note: channel.home
CurlUtil.chpl:84: called as setopt(ch: channel(true,dynamic,true), opt: int(32), arg: slist)
note: generic instantiations are underlined in the above callstackA
``` runtime error is
**Compile command:**
make in Chapel project root directory
**Execution command:**
<!-- e.g. `./foo -nl 4`
If an input file is required, include it as well. -->
**Associated Future Test(s):**
<!-- Are there any tests in Chapel's test system that demonstrate this issue?
e.g. [`test/path/to/foo.chpl`](
https://github.com/chapel-lang/chapel/blob/main/test/path/to/foo.chpl
) #1234 -->
### Configuration Information
- Output of `chpl --version`:
- Output of `$CHPL_HOME/util/printchplenv --anonymize`:
- Back-end compiler and version, e.g. `gcc --version` or `clang --version`:
- (For Cray systems only) Output of `module list`: