fix POST data not working without string literals
https://curl.se/libcurl/c/curl_easy_setopt.html Strings passed to libcurl as 'char *' arguments, are copied by the library; the string storage associated to the pointer argument may be discarded or reused after curl_easy_setopt returns. The only exception to this rule is really CURLOPT_POSTFIELDS
This commit is contained in:
parent
d30021db16
commit
b291110ffa
3 changed files with 3 additions and 2 deletions
2
curl.bqn
2
curl.bqn
|
@ -116,8 +116,8 @@ SetTimeoutms←{timeoutms 𝕊 session:
|
|||
# Use a POST method and set data to post
|
||||
SetData←{data 𝕊 session:
|
||||
"setting up POST request"Check EasySetoptLong⟨session.sessionPtr,curlOptions.post,1⟩
|
||||
"setting POST data"Check EasySetoptStr⟨session.sessionPtr,curlOptions.postfields,data⟩
|
||||
"setting POST data size"Check EasySetoptLong⟨session.sessionPtr,curlOptions.postfieldsize,≠data⟩
|
||||
"copying POST data"Check EasySetoptStr⟨session.sessionPtr,curlOptions.copypostfields,data⟩
|
||||
session
|
||||
}
|
||||
|
||||
|
|
1
ffi.bqn
1
ffi.bqn
|
@ -62,6 +62,7 @@ curlOptions←{
|
|||
|
||||
# long integer options
|
||||
postfieldsize⇐60 # size of the POST input data
|
||||
copypostfields⇐10165 # copy POST input data
|
||||
timeout⇐78 # timeout in seconds
|
||||
timeoutms⇐155 # timeout in milliseconds
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ simpleAPI_testsuite←⟨
|
|||
},
|
||||
"simple POST with headers"‿{𝕊𝕩:
|
||||
headers←⟨"Content-Type: application/json"⟩
|
||||
r←headers Post ⟨httpbinURL∾"/post","{""key"": ""value""}"⟩
|
||||
r←headers Post ⟨httpbinURL∾"/post",¯1000 + 1000 + "{""key"": 1}"⟩
|
||||
! 200=r.code
|
||||
! 0=r.redirectCount
|
||||
! 1=⊑"HTTP/"⍷r.headers
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue