We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
DaemonApiMixin.events does not propagate HttpHeaders from config.json
The docker.api.daemon.DaemonApiMixin.events does not make use of the config.json, which could have custom HTTP headers to pass to the server.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `docker/api/daemon.py`
Content:
```
1 import os
2 import warnings
3 from datetime import datetime
4 
5 from .. import auth, utils
6 from ..constants import INSECURE_REGISTRY_DEPRECATION_WARNING
7 
8 
9 class DaemonApiMixin(object):
10     def events(self, since=None, until=None, filters=None, decode=None):
11         """
12         Get real-time events from the server. Similar to the ``docker events``
13         command.
14 
15         Args:
16             since (UTC datetime or int): Get events from this point
17             until (UTC datetime or int): Get events until this point
18             filters (dict): Filter the events by event time, container or image
19             decode (bool): If set to true, stream will be decoded into dicts on
20                 the fly. False by default.
21 
22         Returns:
23             (generator): A blocking generator you can iterate over to retrieve
24                 events as they happen.
25 
26         Raises:
27             :py:class:`docker.errors.APIError`
28                 If the server returns an error.
29 
30         Example:
31 
32             >>> for event in client.events()
33             ...   print event
34             {u'from': u'image/with:tag',
35              u'id': u'container-id',
36              u'status': u'start',
37              u'time': 1423339459}
38             ...
39         """
40 
41         if isinstance(since, datetime):
42             since = utils.datetime_to_timestamp(since)
43 
44         if isinstance(until, datetime):
45             until = utils.datetime_to_timestamp(until)
46 
47         if filters:
48             filters = utils.convert_filters(filters)
49 
50         params = {
51             'since': since,
52             'until': until,
53             'filters': filters
54         }
55 
56         return self._stream_helper(
57             self.get(self._url('/events'), params=params, stream=True),
58             decode=decode
59         )
60 
61     def info(self):
62         """
63         Display system-wide information. Identical to the ``docker info``
64         command.
65 
66         Returns:
67             (dict): The info as a dict
68 
69         Raises:
70             :py:class:`docker.errors.APIError`
71                 If the server returns an error.
72         """
73         return self._result(self._get(self._url("/info")), True)
74 
75     def login(self, username, password=None, email=None, registry=None,
76               reauth=False, insecure_registry=False, dockercfg_path=None):
77         """
78         Authenticate with a registry. Similar to the ``docker login`` command.
79 
80         Args:
81             username (str): The registry username
82             password (str): The plaintext password
83             email (str): The email for the registry account
84             registry (str): URL to the registry.  E.g.
85                 ``https://index.docker.io/v1/``
86             reauth (bool): Whether refresh existing authentication on the
87                 Docker server.
88             dockercfg_path (str): Use a custom path for the ``.dockercfg`` file
89         (default ``$HOME/.dockercfg``)
90 
91         Returns:
92             (dict): The response from the login request
93 
94         Raises:
95             :py:class:`docker.errors.APIError`
96                 If the server returns an error.
97         """
98         if insecure_registry:
99             warnings.warn(
100                 INSECURE_REGISTRY_DEPRECATION_WARNING.format('login()'),
101                 DeprecationWarning
102             )
103 
104         # If we don't have any auth data so far, try reloading the config file
105         # one more time in case anything showed up in there.
106         # If dockercfg_path is passed check to see if the config file exists,
107         # if so load that config.
108         if dockercfg_path and os.path.exists(dockercfg_path):
109             self._auth_configs = auth.load_config(dockercfg_path)
110         elif not self._auth_configs:
111             self._auth_configs = auth.load_config()
112 
113         authcfg = auth.resolve_authconfig(self._auth_configs, registry)
114         # If we found an existing auth config for this registry and username
115         # combination, we can return it immediately unless reauth is requested.
116         if authcfg and authcfg.get('username', None) == username \
117                 and not reauth:
118             return authcfg
119 
120         req_data = {
121             'username': username,
122             'password': password,
123             'email': email,
124             'serveraddress': registry,
125         }
126 
127         response = self._post_json(self._url('/auth'), data=req_data)
128         if response.status_code == 200:
129             self._auth_configs[registry or auth.INDEX_NAME] = req_data
130         return self._result(response, json=True)
131 
132     def ping(self):
133         """
134         Checks the server is responsive. An exception will be raised if it
135         isn't responding.
136 
137         Returns:
138             (bool) The response from the server.
139 
140         Raises:
141             :py:class:`docker.errors.APIError`
142                 If the server returns an error.
143         """
144         return self._result(self._get(self._url('/_ping'))) == 'OK'
145 
146     def version(self, api_version=True):
147         """
148         Returns version information from the server. Similar to the ``docker
149         version`` command.
150 
151         Returns:
152             (dict): The server version information
153 
154         Raises:
155             :py:class:`docker.errors.APIError`
156                 If the server returns an error.
157         """
158         url = self._url("/version", versioned_api=api_version)
159         return self._result(self._get(url), json=True)
160
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/docker/api/daemon.py b/docker/api/daemon.py
--- a/docker/api/daemon.py
+++ b/docker/api/daemon.py
@@ -54,7 +54,7 @@
         }
 
         return self._stream_helper(
-            self.get(self._url('/events'), params=params, stream=True),
+            self._get(self._url('/events'), params=params, stream=True),
             decode=decode
         )

{"golden_diff": "diff --git a/docker/api/daemon.py b/docker/api/daemon.py\n--- a/docker/api/daemon.py\n+++ b/docker/api/daemon.py\n@@ -54,7 +54,7 @@\n         }\n \n         return self._stream_helper(\n-            self.get(self._url('/events'), params=params, stream=True),\n+            self._get(self._url('/events'), params=params, stream=True),\n             decode=decode\n         )\n", "issue": "DaemonApiMixin.events does not propagate HttpHeaders from config.json\nThe docker.api.daemon.DaemonApiMixin.events does not make use of the config.json, which could have custom HTTP headers to pass to the server.\n", "before_files": [{"content": "import os\nimport warnings\nfrom datetime import datetime\n\nfrom .. import auth, utils\nfrom ..constants import INSECURE_REGISTRY_DEPRECATION_WARNING\n\n\nclass DaemonApiMixin(object):\n    def events(self, since=None, until=None, filters=None, decode=None):\n        \"\"\"\n        Get real-time events from the server. Similar to the ``docker events``\n        command.\n\n        Args:\n            since (UTC datetime or int): Get events from this point\n            until (UTC datetime or int): Get events until this point\n            filters (dict): Filter the events by event time, container or image\n            decode (bool): If set to true, stream will be decoded into dicts on\n                the fly. False by default.\n\n        Returns:\n            (generator): A blocking generator you can iterate over to retrieve\n                events as they happen.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n\n        Example:\n\n            >>> for event in client.events()\n            ...   print event\n            {u'from': u'image/with:tag',\n             u'id': u'container-id',\n             u'status': u'start',\n             u'time': 1423339459}\n            ...\n        \"\"\"\n\n        if isinstance(since, datetime):\n            since = utils.datetime_to_timestamp(since)\n\n        if isinstance(until, datetime):\n            until = utils.datetime_to_timestamp(until)\n\n        if filters:\n            filters = utils.convert_filters(filters)\n\n        params = {\n            'since': since,\n            'until': until,\n            'filters': filters\n        }\n\n        return self._stream_helper(\n            self.get(self._url('/events'), params=params, stream=True),\n            decode=decode\n        )\n\n    def info(self):\n        \"\"\"\n        Display system-wide information. Identical to the ``docker info``\n        command.\n\n        Returns:\n            (dict): The info as a dict\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        return self._result(self._get(self._url(\"/info\")), True)\n\n    def login(self, username, password=None, email=None, registry=None,\n              reauth=False, insecure_registry=False, dockercfg_path=None):\n        \"\"\"\n        Authenticate with a registry. Similar to the ``docker login`` command.\n\n        Args:\n            username (str): The registry username\n            password (str): The plaintext password\n            email (str): The email for the registry account\n            registry (str): URL to the registry.  E.g.\n                ``https://index.docker.io/v1/``\n            reauth (bool): Whether refresh existing authentication on the\n                Docker server.\n            dockercfg_path (str): Use a custom path for the ``.dockercfg`` file\n        (default ``$HOME/.dockercfg``)\n\n        Returns:\n            (dict): The response from the login request\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        if insecure_registry:\n            warnings.warn(\n                INSECURE_REGISTRY_DEPRECATION_WARNING.format('login()'),\n                DeprecationWarning\n            )\n\n        # If we don't have any auth data so far, try reloading the config file\n        # one more time in case anything showed up in there.\n        # If dockercfg_path is passed check to see if the config file exists,\n        # if so load that config.\n        if dockercfg_path and os.path.exists(dockercfg_path):\n            self._auth_configs = auth.load_config(dockercfg_path)\n        elif not self._auth_configs:\n            self._auth_configs = auth.load_config()\n\n        authcfg = auth.resolve_authconfig(self._auth_configs, registry)\n        # If we found an existing auth config for this registry and username\n        # combination, we can return it immediately unless reauth is requested.\n        if authcfg and authcfg.get('username', None) == username \\\n                and not reauth:\n            return authcfg\n\n        req_data = {\n            'username': username,\n            'password': password,\n            'email': email,\n            'serveraddress': registry,\n        }\n\n        response = self._post_json(self._url('/auth'), data=req_data)\n        if response.status_code == 200:\n            self._auth_configs[registry or auth.INDEX_NAME] = req_data\n        return self._result(response, json=True)\n\n    def ping(self):\n        \"\"\"\n        Checks the server is responsive. An exception will be raised if it\n        isn't responding.\n\n        Returns:\n            (bool) The response from the server.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        return self._result(self._get(self._url('/_ping'))) == 'OK'\n\n    def version(self, api_version=True):\n        \"\"\"\n        Returns version information from the server. Similar to the ``docker\n        version`` command.\n\n        Returns:\n            (dict): The server version information\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        url = self._url(\"/version\", versioned_api=api_version)\n        return self._result(self._get(url), json=True)\n", "path": "docker/api/daemon.py"}], "after_files": [{"content": "import os\nimport warnings\nfrom datetime import datetime\n\nfrom .. import auth, utils\nfrom ..constants import INSECURE_REGISTRY_DEPRECATION_WARNING\n\n\nclass DaemonApiMixin(object):\n    def events(self, since=None, until=None, filters=None, decode=None):\n        \"\"\"\n        Get real-time events from the server. Similar to the ``docker events``\n        command.\n\n        Args:\n            since (UTC datetime or int): Get events from this point\n            until (UTC datetime or int): Get events until this point\n            filters (dict): Filter the events by event time, container or image\n            decode (bool): If set to true, stream will be decoded into dicts on\n                the fly. False by default.\n\n        Returns:\n            (generator): A blocking generator you can iterate over to retrieve\n                events as they happen.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n\n        Example:\n\n            >>> for event in client.events()\n            ...   print event\n            {u'from': u'image/with:tag',\n             u'id': u'container-id',\n             u'status': u'start',\n             u'time': 1423339459}\n            ...\n        \"\"\"\n\n        if isinstance(since, datetime):\n            since = utils.datetime_to_timestamp(since)\n\n        if isinstance(until, datetime):\n            until = utils.datetime_to_timestamp(until)\n\n        if filters:\n            filters = utils.convert_filters(filters)\n\n        params = {\n            'since': since,\n            'until': until,\n            'filters': filters\n        }\n\n        return self._stream_helper(\n            self._get(self._url('/events'), params=params, stream=True),\n            decode=decode\n        )\n\n    def info(self):\n        \"\"\"\n        Display system-wide information. Identical to the ``docker info``\n        command.\n\n        Returns:\n            (dict): The info as a dict\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        return self._result(self._get(self._url(\"/info\")), True)\n\n    def login(self, username, password=None, email=None, registry=None,\n              reauth=False, insecure_registry=False, dockercfg_path=None):\n        \"\"\"\n        Authenticate with a registry. Similar to the ``docker login`` command.\n\n        Args:\n            username (str): The registry username\n            password (str): The plaintext password\n            email (str): The email for the registry account\n            registry (str): URL to the registry.  E.g.\n                ``https://index.docker.io/v1/``\n            reauth (bool): Whether refresh existing authentication on the\n                Docker server.\n            dockercfg_path (str): Use a custom path for the ``.dockercfg`` file\n        (default ``$HOME/.dockercfg``)\n\n        Returns:\n            (dict): The response from the login request\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        if insecure_registry:\n            warnings.warn(\n                INSECURE_REGISTRY_DEPRECATION_WARNING.format('login()'),\n                DeprecationWarning\n            )\n\n        # If we don't have any auth data so far, try reloading the config file\n        # one more time in case anything showed up in there.\n        # If dockercfg_path is passed check to see if the config file exists,\n        # if so load that config.\n        if dockercfg_path and os.path.exists(dockercfg_path):\n            self._auth_configs = auth.load_config(dockercfg_path)\n        elif not self._auth_configs:\n            self._auth_configs = auth.load_config()\n\n        authcfg = auth.resolve_authconfig(self._auth_configs, registry)\n        # If we found an existing auth config for this registry and username\n        # combination, we can return it immediately unless reauth is requested.\n        if authcfg and authcfg.get('username', None) == username \\\n                and not reauth:\n            return authcfg\n\n        req_data = {\n            'username': username,\n            'password': password,\n            'email': email,\n            'serveraddress': registry,\n        }\n\n        response = self._post_json(self._url('/auth'), data=req_data)\n        if response.status_code == 200:\n            self._auth_configs[registry or auth.INDEX_NAME] = req_data\n        return self._result(response, json=True)\n\n    def ping(self):\n        \"\"\"\n        Checks the server is responsive. An exception will be raised if it\n        isn't responding.\n\n        Returns:\n            (bool) The response from the server.\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        return self._result(self._get(self._url('/_ping'))) == 'OK'\n\n    def version(self, api_version=True):\n        \"\"\"\n        Returns version information from the server. Similar to the ``docker\n        version`` command.\n\n        Returns:\n            (dict): The server version information\n\n        Raises:\n            :py:class:`docker.errors.APIError`\n                If the server returns an error.\n        \"\"\"\n        url = self._url(\"/version\", versioned_api=api_version)\n        return self._result(self._get(url), json=True)\n", "path": "docker/api/daemon.py"}]}