r-lib / httr2

Make HTTP requests and process their responses. A modern reimagining of httr.
https://httr2.r-lib.org
Other
235 stars 56 forks source link

`curl_translate()` bugs #500

Open mgirlich opened 2 months ago

mgirlich commented 2 months ago

A couple of bugs I found when creating the PR for curlconverter.com

Crashes

library(httr2)
curl_translate("curl -X GET \"http://localhost:28139/cookies\" -H \"accept: application/json\" -H 'Cookie: mysamplecookie=someValue; emptycookie=; otherCookie=2'")
#> Error in `httr2::url_parse()`:
#> ! `url` must be a single string, not a character vector.

Wrong url

curl_translate("curl httpbin.org")
#> request("/httpbin.org") |> 
#>   req_perform()

Missing headers:

curl_translate("curl --header \"Content-Type: text/xml;charset=UTF-8\" --header \"getWorkOrderCancel;\" localhost:28139/get")
#> request("localhost:///28139/get") |> 
#>   req_perform()

Created on 2024-07-12 with reprex v2.1.0