refactor client.connect

fix client.connect() method to allow to pass additional headers (e.g. a
client-id header in issue i#32).

The change is backwards compatible so that Web applications should not
have to change their call to work.