Closed dlight closed 6 years ago
Yo Dowg
Thanks for the patch.
Now with the option --dry-run
you can output the command that us given to curl.
For supporting Not sure I want to hack around for this very specific edge case. But if you came out with a solution I would welcome a PR with pleasure. :)
By the way Sorry for the long answer time :/
I use urls as my couchdb keys (maybe this is dumb, but nevermind). so I need to do things like
PUT "/$url"
with resty.
You say on your documentation that I need to escape /; all the rest, resty will handle. I substituted / to %2F on $url. but it saves with %2F on the key name, not /; somehow resty is also escaping %, where it shouldn't.
PUT '/http:%2F%2Fwww.test.com' '{"a": 5}' {"ok":true,"id":"http:%2F%2Fwww.test.com","rev":"1-8bf226e57847cf49b0d45065383cf323"}
(should return "id":"http://www.test.com")
sending unescaped obviously doesn't help
PUT '/http://www.test.com' '{"a": 5}' {"ok":true,"id":"http:","rev":"1-c04faa654c092ab691c6d82f2b57f90d"}
you say -Q prevents escaping. but then somehow www.test.com is saved as an attachment
PUT -Q '/http:%2F%2Fwww.test.com' '{"a": 5}' {"ok":true,"id":"http:","rev":"1-38668c8ceb94ab26818d36f8139af49c"} GET '/http:' {"_id":"http:","_rev":"1-38668c8ceb94ab26818d36f8139af49c","_attachments":{"www.test.com":{"content_type":"application/octet-stream","revpos":1,"length":0,"stub":true}}}
unfortunately your -v shows the curl response, but not the curl command line. I was able to see it using an (ugly) custom debug. then I figured out a workaround for my case:
curl -X PUT "http://127.0.0.1/dbname/$urlwithslashesescaped" -d "$newdoc"
so, long story short, after struggling with resty for a while, I opted to use curl directly for this request (but I'm still using resty for my other requests)
I know my case is edgy so I don't know what your tool could do for me. I produced a patch that shows curl command line with resty -v
ps: this resty tool (and jsawk) is awesome!