URLRequest extension that creates a cURL command string
URLRequest-cURL is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'URLRequest-cURL'
// let request = URLRequest()
print(request.cURL)
Simple var 'cURL' gives the following string:
curl -X POST 'https://www.anonymousapi.com/checksPassword?apikey=XXYYZZ' -H 'Accept-Language: en' -H 'Content-Length: 91' -H 'Content-Type: application/json' -d '{
"email" : "[email protected]",
"returnSecureToken" : true,
"password" : "password"
}'
You can also choose to ommit http headers
// let request = URLRequest()
print(request.cURL(withHeaders: false))
function 'cURL' ommitting headers gives the following string:
curl -X POST 'https://www.anonymousapi.com/checksPassword?apikey=XXYYZZ' -d '{
"email" : "[email protected]",
"returnSecureToken" : true,
"password" : "password"
}'