doc: improved the code examples in Synopsis

* added proper error handling code for request_uri(), request(), and
  set_keepalive() calls to help trouble-shooting.
* removed line-trailing spaces.