How to get response and it header ??
It is first to use this tool, and I don't know how to get response from it.
For example, I curl a url like "https://www.github.com" then How can I see the response and it header from it ??
CUrl curl = new CUrl('https://www.github.com'); String resp = curl.exec(CUrl.UTF8, null); List<String[]> headers = curl.getResponseHeaders()[0];
Thanks, It works, but I still have some question
- if url is can't visit it will raise IOException, how to ignore it ??
- can see response in key-value ??
- it RESTful work now (like --request POST, DELETE), if not, how to use it like RESTful api ??
- you can write your own Resolver to avoid throwing a fatal Exception
- you need other library to parse json data, e.g. jackson, gson etc.
- they should be working, if not, please report another issue
Can you teach how to use get, post, delete by this jar ?? because doc says --request is not support on this jar.
'--request' or '-X' is supprted but without a shortcut method, that means you'd have to use opt() method, e.g.: new CUrl(...).opt('-X', 'DELETE')
Yeah, it work ~~~~~~~~~~ last question, can you teach me how to write a resolver ?? I have search a l ot of info but can not find it.
: ) Thanks and best regard.
you can write your own Resolver to avoid throwing a fatal Exception
sorry for misleading, Resolver is not designed to handle exceptions, it's mostly like a data converter, however it can be used to indicate a normal response (i.e. with HTTP status 200) to be biz-error and can be retried. actually CUrl does not "raise/throw" any connection Exceptions, instead, it dumps them into 'stderr', that is a CUrl.IO instance which is by default the same instance with 'stdout'.