We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Ability to not send specific headers in HTTP requests
Some web servers behave differently when they are receive or don't receive specific headers.

For example FeedBurner (http://feeds.feedburner.com/someblog) sends out XML RSS feeds **only is you do not set the "Referer" header.**

The idea would be to use the `headers` dict with some keys with a `None` value, and skip these headers when sending the HTTP request.

Currently, for the "Referer" example:
- `headers={"Referer": None}` sends "Referer: None"
- `headers={"Referer": ""}` sends "Referer: " (which works for the FeedBurner case, but is not satisfactory)
- disable `RefererMiddleware` but that feels a bit heavy

(for this FeedBurner thing, apparently adding `?format=xml` also does the trick)


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `scrapy/http/headers.py`
Content:
```
1 from w3lib.http import headers_dict_to_raw
2 from scrapy.utils.datatypes import CaselessDict
3 
4 
5 class Headers(CaselessDict):
6     """Case insensitive http headers dictionary"""
7 
8     def __init__(self, seq=None, encoding='utf-8'):
9         self.encoding = encoding
10         super(Headers, self).__init__(seq)
11 
12     def normkey(self, key):
13         """Headers must not be unicode"""
14         if isinstance(key, unicode):
15             return key.title().encode(self.encoding)
16         return key.title()
17 
18     def normvalue(self, value):
19         """Headers must not be unicode"""
20         if not hasattr(value, '__iter__'):
21             value = [value]
22         return [x.encode(self.encoding) if isinstance(x, unicode) else x \
23             for x in value]
24 
25     def __getitem__(self, key):
26         try:
27             return super(Headers, self).__getitem__(key)[-1]
28         except IndexError:
29             return None
30 
31     def get(self, key, def_val=None):
32         try:
33             return super(Headers, self).get(key, def_val)[-1]
34         except IndexError:
35             return None
36 
37     def getlist(self, key, def_val=None):
38         try:
39             return super(Headers, self).__getitem__(key)
40         except KeyError:
41             if def_val is not None:
42                 return self.normvalue(def_val)
43             return []
44 
45     def setlist(self, key, list_):
46         self[key] = list_
47 
48     def setlistdefault(self, key, default_list=()):
49         return self.setdefault(key, default_list)
50 
51     def appendlist(self, key, value):
52         lst = self.getlist(key)
53         lst.extend(self.normvalue(value))
54         self[key] = lst
55 
56     def items(self):
57         return list(self.iteritems())
58 
59     def iteritems(self):
60         return ((k, self.getlist(k)) for k in self.keys())
61 
62     def values(self):
63         return [self[k] for k in self.keys()]
64 
65     def to_string(self):
66         return headers_dict_to_raw(self)
67 
68     def __copy__(self):
69         return self.__class__(self)
70     copy = __copy__
71 
72 
73
```
--- 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/scrapy/http/headers.py b/scrapy/http/headers.py
--- a/scrapy/http/headers.py
+++ b/scrapy/http/headers.py
@@ -17,7 +17,9 @@
 
     def normvalue(self, value):
         """Headers must not be unicode"""
-        if not hasattr(value, '__iter__'):
+        if value is None:
+            value = []
+        elif not hasattr(value, '__iter__'):
             value = [value]
         return [x.encode(self.encoding) if isinstance(x, unicode) else x \
             for x in value]

{"golden_diff": "diff --git a/scrapy/http/headers.py b/scrapy/http/headers.py\n--- a/scrapy/http/headers.py\n+++ b/scrapy/http/headers.py\n@@ -17,7 +17,9 @@\n \n     def normvalue(self, value):\n         \"\"\"Headers must not be unicode\"\"\"\n-        if not hasattr(value, '__iter__'):\n+        if value is None:\n+            value = []\n+        elif not hasattr(value, '__iter__'):\n             value = [value]\n         return [x.encode(self.encoding) if isinstance(x, unicode) else x \\\n             for x in value]\n", "issue": "Ability to not send specific headers in HTTP requests\nSome web servers behave differently when they are receive or don't receive specific headers.\n\nFor example FeedBurner (http://feeds.feedburner.com/someblog) sends out XML RSS feeds **only is you do not set the \"Referer\" header.**\n\nThe idea would be to use the `headers` dict with some keys with a `None` value, and skip these headers when sending the HTTP request.\n\nCurrently, for the \"Referer\" example:\n- `headers={\"Referer\": None}` sends \"Referer: None\"\n- `headers={\"Referer\": \"\"}` sends \"Referer: \" (which works for the FeedBurner case, but is not satisfactory)\n- disable `RefererMiddleware` but that feels a bit heavy\n\n(for this FeedBurner thing, apparently adding `?format=xml` also does the trick)\n\n", "before_files": [{"content": "from w3lib.http import headers_dict_to_raw\nfrom scrapy.utils.datatypes import CaselessDict\n\n\nclass Headers(CaselessDict):\n    \"\"\"Case insensitive http headers dictionary\"\"\"\n\n    def __init__(self, seq=None, encoding='utf-8'):\n        self.encoding = encoding\n        super(Headers, self).__init__(seq)\n\n    def normkey(self, key):\n        \"\"\"Headers must not be unicode\"\"\"\n        if isinstance(key, unicode):\n            return key.title().encode(self.encoding)\n        return key.title()\n\n    def normvalue(self, value):\n        \"\"\"Headers must not be unicode\"\"\"\n        if not hasattr(value, '__iter__'):\n            value = [value]\n        return [x.encode(self.encoding) if isinstance(x, unicode) else x \\\n            for x in value]\n\n    def __getitem__(self, key):\n        try:\n            return super(Headers, self).__getitem__(key)[-1]\n        except IndexError:\n            return None\n\n    def get(self, key, def_val=None):\n        try:\n            return super(Headers, self).get(key, def_val)[-1]\n        except IndexError:\n            return None\n\n    def getlist(self, key, def_val=None):\n        try:\n            return super(Headers, self).__getitem__(key)\n        except KeyError:\n            if def_val is not None:\n                return self.normvalue(def_val)\n            return []\n\n    def setlist(self, key, list_):\n        self[key] = list_\n\n    def setlistdefault(self, key, default_list=()):\n        return self.setdefault(key, default_list)\n\n    def appendlist(self, key, value):\n        lst = self.getlist(key)\n        lst.extend(self.normvalue(value))\n        self[key] = lst\n\n    def items(self):\n        return list(self.iteritems())\n\n    def iteritems(self):\n        return ((k, self.getlist(k)) for k in self.keys())\n\n    def values(self):\n        return [self[k] for k in self.keys()]\n\n    def to_string(self):\n        return headers_dict_to_raw(self)\n\n    def __copy__(self):\n        return self.__class__(self)\n    copy = __copy__\n\n\n", "path": "scrapy/http/headers.py"}], "after_files": [{"content": "from w3lib.http import headers_dict_to_raw\nfrom scrapy.utils.datatypes import CaselessDict\n\n\nclass Headers(CaselessDict):\n    \"\"\"Case insensitive http headers dictionary\"\"\"\n\n    def __init__(self, seq=None, encoding='utf-8'):\n        self.encoding = encoding\n        super(Headers, self).__init__(seq)\n\n    def normkey(self, key):\n        \"\"\"Headers must not be unicode\"\"\"\n        if isinstance(key, unicode):\n            return key.title().encode(self.encoding)\n        return key.title()\n\n    def normvalue(self, value):\n        \"\"\"Headers must not be unicode\"\"\"\n        if value is None:\n            value = []\n        elif not hasattr(value, '__iter__'):\n            value = [value]\n        return [x.encode(self.encoding) if isinstance(x, unicode) else x \\\n            for x in value]\n\n    def __getitem__(self, key):\n        try:\n            return super(Headers, self).__getitem__(key)[-1]\n        except IndexError:\n            return None\n\n    def get(self, key, def_val=None):\n        try:\n            return super(Headers, self).get(key, def_val)[-1]\n        except IndexError:\n            return None\n\n    def getlist(self, key, def_val=None):\n        try:\n            return super(Headers, self).__getitem__(key)\n        except KeyError:\n            if def_val is not None:\n                return self.normvalue(def_val)\n            return []\n\n    def setlist(self, key, list_):\n        self[key] = list_\n\n    def setlistdefault(self, key, default_list=()):\n        return self.setdefault(key, default_list)\n\n    def appendlist(self, key, value):\n        lst = self.getlist(key)\n        lst.extend(self.normvalue(value))\n        self[key] = lst\n\n    def items(self):\n        return list(self.iteritems())\n\n    def iteritems(self):\n        return ((k, self.getlist(k)) for k in self.keys())\n\n    def values(self):\n        return [self[k] for k in self.keys()]\n\n    def to_string(self):\n        return headers_dict_to_raw(self)\n\n    def __copy__(self):\n        return self.__class__(self)\n    copy = __copy__\n\n\n", "path": "scrapy/http/headers.py"}]}