Skip to content

Commit

Permalink
Work around missing options in old libcurl, fixes #192
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Aug 27, 2019
1 parent 8f64a1a commit 327ae62
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/handle.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ SEXP R_handle_setopt(SEXP ptr, SEXP keys, SEXP values){
error("Value for option %s (%d) must be a number.", optname, key);
}
assert(curl_easy_setopt(handle, key, (curl_off_t) asReal(val)));
} else if(r_curl_is_string_option(key) || r_curl_is_postfields_option(key)){
} else if(r_curl_is_postfields_option(key) || r_curl_is_string_option(key)){
switch (TYPEOF(val)) {
case RAWSXP:
if(key == CURLOPT_POSTFIELDS || key == CURLOPT_COPYPOSTFIELDS)
Expand Down
6 changes: 5 additions & 1 deletion src/typechecking.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,12 @@ int r_curl_is_off_t_option(CURLoption x){
return _curl_is_off_t_option(x);
}

/* workaround old curl bug: if an option is neither classified as string
* stringlist, we assume string: /~https://github.com/jeroen/curl/issues/192
*/
int r_curl_is_string_option(CURLoption x){
return _curl_is_string_option(x);
return _curl_is_string_option(x) ||
(x > 10000 && x < 20000 && !r_curl_is_slist_option(x));
}

int r_curl_is_postfields_option(CURLoption x){
Expand Down

0 comments on commit 327ae62

Please sign in to comment.