Don't call curl functions unless needed.

Fix bug where diemsg is freed early.
Make sure examples/checkip.ff handles Network I/O fail.
Fix error message related memory leaks.