We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Client.build crashes when trying to pull a new image if HttpHeaders are set in config file
``` python

import docker

c = docker.Client()
c.build('https://github.com/docker/compose.git')
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-d78c607c9627> in <module>()
----> 1 c.build('https://github.com/docker/compose.git')

/home/joffrey/.envs/pydocker/local/lib/python2.7/site-packages/docker/api/build.pyc in build(self, path, tag, quiet, fileobj, nocache, rm, stream, timeout, custom_context, encoding, pull, forcerm, dockerfile, container_limits, decode, buildargs, gzip)
    102             headers=headers,
    103             stream=stream,
--> 104             timeout=timeout,
    105         )
    106 

/home/joffrey/.envs/pydocker/local/lib/python2.7/site-packages/docker/utils/decorators.pyc in inner(self, *args, **kwargs)
     44                 kwargs['headers'] = self._auth_configs['HttpHeaders']
     45             else:
---> 46                 kwargs['headers'].update(self._auth_configs['HttpHeaders'])
     47         return f(self, *args, **kwargs)
     48     return inner

AttributeError: 'NoneType' object has no attribute 'update'
```


--- 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/utils/decorators.py`
Content:
```
1 import functools
2 
3 from .. import errors
4 from . import utils
5 
6 
7 def check_resource(f):
8     @functools.wraps(f)
9     def wrapped(self, resource_id=None, *args, **kwargs):
10         if resource_id is None:
11             if kwargs.get('container'):
12                 resource_id = kwargs.pop('container')
13             elif kwargs.get('image'):
14                 resource_id = kwargs.pop('image')
15         if isinstance(resource_id, dict):
16             resource_id = resource_id.get('Id')
17         if not resource_id:
18             raise errors.NullResource(
19                 'image or container param is undefined'
20             )
21         return f(self, resource_id, *args, **kwargs)
22     return wrapped
23 
24 
25 def minimum_version(version):
26     def decorator(f):
27         @functools.wraps(f)
28         def wrapper(self, *args, **kwargs):
29             if utils.version_lt(self._version, version):
30                 raise errors.InvalidVersion(
31                     '{0} is not available for version < {1}'.format(
32                         f.__name__, version
33                     )
34                 )
35             return f(self, *args, **kwargs)
36         return wrapper
37     return decorator
38 
39 
40 def update_headers(f):
41     def inner(self, *args, **kwargs):
42         if 'HttpHeaders' in self._auth_configs:
43             if 'headers' not in kwargs:
44                 kwargs['headers'] = self._auth_configs['HttpHeaders']
45             else:
46                 kwargs['headers'].update(self._auth_configs['HttpHeaders'])
47         return f(self, *args, **kwargs)
48     return inner
49
```
--- 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/utils/decorators.py b/docker/utils/decorators.py
--- a/docker/utils/decorators.py
+++ b/docker/utils/decorators.py
@@ -40,7 +40,7 @@
 def update_headers(f):
     def inner(self, *args, **kwargs):
         if 'HttpHeaders' in self._auth_configs:
-            if 'headers' not in kwargs:
+            if not kwargs.get('headers'):
                 kwargs['headers'] = self._auth_configs['HttpHeaders']
             else:
                 kwargs['headers'].update(self._auth_configs['HttpHeaders'])

{"golden_diff": "diff --git a/docker/utils/decorators.py b/docker/utils/decorators.py\n--- a/docker/utils/decorators.py\n+++ b/docker/utils/decorators.py\n@@ -40,7 +40,7 @@\n def update_headers(f):\n     def inner(self, *args, **kwargs):\n         if 'HttpHeaders' in self._auth_configs:\n-            if 'headers' not in kwargs:\n+            if not kwargs.get('headers'):\n                 kwargs['headers'] = self._auth_configs['HttpHeaders']\n             else:\n                 kwargs['headers'].update(self._auth_configs['HttpHeaders'])\n", "issue": "Client.build crashes when trying to pull a new image if HttpHeaders are set in config file\n``` python\n\nimport docker\n\nc = docker.Client()\nc.build('https://github.com/docker/compose.git')\n---------------------------------------------------------------------------\nAttributeError                            Traceback (most recent call last)\n<ipython-input-3-d78c607c9627> in <module>()\n----> 1 c.build('https://github.com/docker/compose.git')\n\n/home/joffrey/.envs/pydocker/local/lib/python2.7/site-packages/docker/api/build.pyc in build(self, path, tag, quiet, fileobj, nocache, rm, stream, timeout, custom_context, encoding, pull, forcerm, dockerfile, container_limits, decode, buildargs, gzip)\n    102             headers=headers,\n    103             stream=stream,\n--> 104             timeout=timeout,\n    105         )\n    106 \n\n/home/joffrey/.envs/pydocker/local/lib/python2.7/site-packages/docker/utils/decorators.pyc in inner(self, *args, **kwargs)\n     44                 kwargs['headers'] = self._auth_configs['HttpHeaders']\n     45             else:\n---> 46                 kwargs['headers'].update(self._auth_configs['HttpHeaders'])\n     47         return f(self, *args, **kwargs)\n     48     return inner\n\nAttributeError: 'NoneType' object has no attribute 'update'\n```\n\n", "before_files": [{"content": "import functools\n\nfrom .. import errors\nfrom . import utils\n\n\ndef check_resource(f):\n    @functools.wraps(f)\n    def wrapped(self, resource_id=None, *args, **kwargs):\n        if resource_id is None:\n            if kwargs.get('container'):\n                resource_id = kwargs.pop('container')\n            elif kwargs.get('image'):\n                resource_id = kwargs.pop('image')\n        if isinstance(resource_id, dict):\n            resource_id = resource_id.get('Id')\n        if not resource_id:\n            raise errors.NullResource(\n                'image or container param is undefined'\n            )\n        return f(self, resource_id, *args, **kwargs)\n    return wrapped\n\n\ndef minimum_version(version):\n    def decorator(f):\n        @functools.wraps(f)\n        def wrapper(self, *args, **kwargs):\n            if utils.version_lt(self._version, version):\n                raise errors.InvalidVersion(\n                    '{0} is not available for version < {1}'.format(\n                        f.__name__, version\n                    )\n                )\n            return f(self, *args, **kwargs)\n        return wrapper\n    return decorator\n\n\ndef update_headers(f):\n    def inner(self, *args, **kwargs):\n        if 'HttpHeaders' in self._auth_configs:\n            if 'headers' not in kwargs:\n                kwargs['headers'] = self._auth_configs['HttpHeaders']\n            else:\n                kwargs['headers'].update(self._auth_configs['HttpHeaders'])\n        return f(self, *args, **kwargs)\n    return inner\n", "path": "docker/utils/decorators.py"}], "after_files": [{"content": "import functools\n\nfrom .. import errors\nfrom . import utils\n\n\ndef check_resource(f):\n    @functools.wraps(f)\n    def wrapped(self, resource_id=None, *args, **kwargs):\n        if resource_id is None:\n            if kwargs.get('container'):\n                resource_id = kwargs.pop('container')\n            elif kwargs.get('image'):\n                resource_id = kwargs.pop('image')\n        if isinstance(resource_id, dict):\n            resource_id = resource_id.get('Id')\n        if not resource_id:\n            raise errors.NullResource(\n                'image or container param is undefined'\n            )\n        return f(self, resource_id, *args, **kwargs)\n    return wrapped\n\n\ndef minimum_version(version):\n    def decorator(f):\n        @functools.wraps(f)\n        def wrapper(self, *args, **kwargs):\n            if utils.version_lt(self._version, version):\n                raise errors.InvalidVersion(\n                    '{0} is not available for version < {1}'.format(\n                        f.__name__, version\n                    )\n                )\n            return f(self, *args, **kwargs)\n        return wrapper\n    return decorator\n\n\ndef update_headers(f):\n    def inner(self, *args, **kwargs):\n        if 'HttpHeaders' in self._auth_configs:\n            if not kwargs.get('headers'):\n                kwargs['headers'] = self._auth_configs['HttpHeaders']\n            else:\n                kwargs['headers'].update(self._auth_configs['HttpHeaders'])\n        return f(self, *args, **kwargs)\n    return inner\n", "path": "docker/utils/decorators.py"}]}