def open(cls, profile, user_agent=None, on_bind=None, on_unbind=None, on_release=None, on_broken=None): """ Open an HTTP connection to a server. :param profile: :class:`.ConnectionProfile` detailing how and where to connect :param user_agent: :param on_bind: :param on_unbind: :param on_release: :param on_broken: :returns: :class:`.HTTP` connection object :raises: :class:`.ConnectionUnavailable` if a connection cannot be opened """ try: http = cls(profile, (user_agent or http_user_agent()), on_bind=on_bind, on_unbind=on_unbind, on_release=on_release) http._hello() return http except HTTPError as error: raise_from( ConnectionUnavailable("Cannot open connection to %r", profile), error)
def open(cls, profile, user_agent=None, on_bind=None, on_unbind=None, on_release=None): http = cls(profile, (user_agent or http_user_agent()), on_bind=on_bind, on_unbind=on_unbind, on_release=on_release) http._hello() return http
def test_http_user_agent(): agent = http_user_agent() assert agent.startswith("py2neo")