We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Download Data Fails if Content Length Not Defined in Header
## 🐛 Bug

When I try to download a zip file using download_data from flash.core.data it fails because the response header does not contain a value for 'Content Length' this should be check for and handled in the code. 

### To Reproduce

Steps to reproduce the behavior:

KeyError                                  Traceback (most recent call last)
<ipython-input-7-aa10e89f3a8e> in <module>()
      1 # 1. Download the data
----> 2 download_data("https://github.com/karoldvl/ESC-50/archive/master.zip", 'data/')

2 frames
/content/gdrive/MyDrive/lightning-flash/flash/core/data/utils.py in download_data(url, path)
     75 
     76     """
---> 77     download_file(url, path)
     78 
     79 

/content/gdrive/MyDrive/lightning-flash/flash/core/data/utils.py in download_file(url, path, verbose)
     36     local_filename = os.path.join(path, url.split('/')[-1])
     37     r = requests.get(url, stream=True)
---> 38     file_size = int(r.headers['Content-Length'])
     39     chunk = 1
     40     chunk_size = 1024

/usr/local/lib/python3.6/dist-packages/requests/structures.py in __getitem__(self, key)
     52 
     53     def __getitem__(self, key):
---> 54         return self._store[key.lower()][1]
     55 
     56     def __delitem__(self, key):

KeyError: 'content-length'
<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->


#### Code sample
<!-- Ideally attach a minimal code sample to reproduce the decried issue.
Minimal means having the shortest code but still preserving the bug. -->

```python
import flash
from flash.core.data import download_data
download_data("https://github.com/karoldvl/ESC-50/archive/master.zip", 'data/')
```

### Expected behavior

File downloads and extracts ESC-50 data into datasets folder

### Environment

Default Collab Configuration 

### Additional context

<!-- Add any other context about the problem here. -->


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `flash/core/data/utils.py`
Content:
```
1 # Copyright The PyTorch Lightning team.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 import os.path
16 import zipfile
17 from typing import Any, Type
18 
19 import requests
20 import torch
21 from tqdm.auto import tqdm as tq
22 
23 
24 # Code taken from: https://gist.github.com/ruxi/5d6803c116ec1130d484a4ab8c00c603
25 # __author__  = "github.com/ruxi"
26 # __license__ = "MIT"
27 def download_file(url: str, path: str, verbose: bool = False) -> None:
28     """
29     Download file with progressbar
30 
31     Usage:
32         download_file('http://web4host.net/5MB.zip')
33     """
34     if not os.path.exists(path):
35         os.makedirs(path)
36     local_filename = os.path.join(path, url.split('/')[-1])
37     r = requests.get(url, stream=True)
38     file_size = int(r.headers['Content-Length'])
39     chunk = 1
40     chunk_size = 1024
41     num_bars = int(file_size / chunk_size)
42     if verbose:
43         print(dict(file_size=file_size))
44         print(dict(num_bars=num_bars))
45 
46     if not os.path.exists(local_filename):
47         with open(local_filename, 'wb') as fp:
48             for chunk in tq(
49                 r.iter_content(chunk_size=chunk_size),
50                 total=num_bars,
51                 unit='KB',
52                 desc=local_filename,
53                 leave=True  # progressbar stays
54             ):
55                 fp.write(chunk)  # type: ignore
56 
57     if '.zip' in local_filename:
58         if os.path.exists(local_filename):
59             with zipfile.ZipFile(local_filename, 'r') as zip_ref:
60                 zip_ref.extractall(path)
61 
62 
63 def download_data(url: str, path: str = "data/") -> None:
64     """
65     Downloads data automatically from the given url to the path. Defaults to data/ for the path.
66     Automatically handles .csv, .zip
67 
68     Example::
69 
70         from flash import download_data
71 
72     Args:
73         url: path
74         path: local
75 
76     """
77     download_file(url, path)
78 
79 
80 def _contains_any_tensor(value: Any, dtype: Type = torch.Tensor) -> bool:
81     # TODO: we should refactor FlashDatasetFolder to better integrate
82     # with DataPipeline. That way, we wouldn't need this check.
83     # This is because we are running transforms in both places.
84     if isinstance(value, dtype):
85         return True
86     if isinstance(value, (list, tuple)):
87         return any(_contains_any_tensor(v, dtype=dtype) for v in value)
88     elif isinstance(value, dict):
89         return any(_contains_any_tensor(v, dtype=dtype) for v in value.values())
90     return False
91
```
--- 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/flash/core/data/utils.py b/flash/core/data/utils.py
--- a/flash/core/data/utils.py
+++ b/flash/core/data/utils.py
@@ -35,7 +35,7 @@
         os.makedirs(path)
     local_filename = os.path.join(path, url.split('/')[-1])
     r = requests.get(url, stream=True)
-    file_size = int(r.headers['Content-Length'])
+    file_size = int(r.headers['Content-Length']) if 'Content-Length' in r.headers else 0
     chunk = 1
     chunk_size = 1024
     num_bars = int(file_size / chunk_size)

{"golden_diff": "diff --git a/flash/core/data/utils.py b/flash/core/data/utils.py\n--- a/flash/core/data/utils.py\n+++ b/flash/core/data/utils.py\n@@ -35,7 +35,7 @@\n         os.makedirs(path)\n     local_filename = os.path.join(path, url.split('/')[-1])\n     r = requests.get(url, stream=True)\n-    file_size = int(r.headers['Content-Length'])\n+    file_size = int(r.headers['Content-Length']) if 'Content-Length' in r.headers else 0\n     chunk = 1\n     chunk_size = 1024\n     num_bars = int(file_size / chunk_size)\n", "issue": "Download Data Fails if Content Length Not Defined in Header\n## \ud83d\udc1b Bug\r\n\r\nWhen I try to download a zip file using download_data from flash.core.data it fails because the response header does not contain a value for 'Content Length' this should be check for and handled in the code. \r\n\r\n### To Reproduce\r\n\r\nSteps to reproduce the behavior:\r\n\r\nKeyError                                  Traceback (most recent call last)\r\n<ipython-input-7-aa10e89f3a8e> in <module>()\r\n      1 # 1. Download the data\r\n----> 2 download_data(\"https://github.com/karoldvl/ESC-50/archive/master.zip\", 'data/')\r\n\r\n2 frames\r\n/content/gdrive/MyDrive/lightning-flash/flash/core/data/utils.py in download_data(url, path)\r\n     75 \r\n     76     \"\"\"\r\n---> 77     download_file(url, path)\r\n     78 \r\n     79 \r\n\r\n/content/gdrive/MyDrive/lightning-flash/flash/core/data/utils.py in download_file(url, path, verbose)\r\n     36     local_filename = os.path.join(path, url.split('/')[-1])\r\n     37     r = requests.get(url, stream=True)\r\n---> 38     file_size = int(r.headers['Content-Length'])\r\n     39     chunk = 1\r\n     40     chunk_size = 1024\r\n\r\n/usr/local/lib/python3.6/dist-packages/requests/structures.py in __getitem__(self, key)\r\n     52 \r\n     53     def __getitem__(self, key):\r\n---> 54         return self._store[key.lower()][1]\r\n     55 \r\n     56     def __delitem__(self, key):\r\n\r\nKeyError: 'content-length'\r\n<!-- If you have a code sample, error messages, stack traces, please provide it here as well -->\r\n\r\n\r\n#### Code sample\r\n<!-- Ideally attach a minimal code sample to reproduce the decried issue.\r\nMinimal means having the shortest code but still preserving the bug. -->\r\n\r\n```python\r\nimport flash\r\nfrom flash.core.data import download_data\r\ndownload_data(\"https://github.com/karoldvl/ESC-50/archive/master.zip\", 'data/')\r\n```\r\n\r\n### Expected behavior\r\n\r\nFile downloads and extracts ESC-50 data into datasets folder\r\n\r\n### Environment\r\n\r\nDefault Collab Configuration \r\n\r\n### Additional context\r\n\r\n<!-- Add any other context about the problem here. -->\r\n\n", "before_files": [{"content": "# Copyright The PyTorch Lightning team.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport os.path\nimport zipfile\nfrom typing import Any, Type\n\nimport requests\nimport torch\nfrom tqdm.auto import tqdm as tq\n\n\n# Code taken from: https://gist.github.com/ruxi/5d6803c116ec1130d484a4ab8c00c603\n# __author__  = \"github.com/ruxi\"\n# __license__ = \"MIT\"\ndef download_file(url: str, path: str, verbose: bool = False) -> None:\n    \"\"\"\n    Download file with progressbar\n\n    Usage:\n        download_file('http://web4host.net/5MB.zip')\n    \"\"\"\n    if not os.path.exists(path):\n        os.makedirs(path)\n    local_filename = os.path.join(path, url.split('/')[-1])\n    r = requests.get(url, stream=True)\n    file_size = int(r.headers['Content-Length'])\n    chunk = 1\n    chunk_size = 1024\n    num_bars = int(file_size / chunk_size)\n    if verbose:\n        print(dict(file_size=file_size))\n        print(dict(num_bars=num_bars))\n\n    if not os.path.exists(local_filename):\n        with open(local_filename, 'wb') as fp:\n            for chunk in tq(\n                r.iter_content(chunk_size=chunk_size),\n                total=num_bars,\n                unit='KB',\n                desc=local_filename,\n                leave=True  # progressbar stays\n            ):\n                fp.write(chunk)  # type: ignore\n\n    if '.zip' in local_filename:\n        if os.path.exists(local_filename):\n            with zipfile.ZipFile(local_filename, 'r') as zip_ref:\n                zip_ref.extractall(path)\n\n\ndef download_data(url: str, path: str = \"data/\") -> None:\n    \"\"\"\n    Downloads data automatically from the given url to the path. Defaults to data/ for the path.\n    Automatically handles .csv, .zip\n\n    Example::\n\n        from flash import download_data\n\n    Args:\n        url: path\n        path: local\n\n    \"\"\"\n    download_file(url, path)\n\n\ndef _contains_any_tensor(value: Any, dtype: Type = torch.Tensor) -> bool:\n    # TODO: we should refactor FlashDatasetFolder to better integrate\n    # with DataPipeline. That way, we wouldn't need this check.\n    # This is because we are running transforms in both places.\n    if isinstance(value, dtype):\n        return True\n    if isinstance(value, (list, tuple)):\n        return any(_contains_any_tensor(v, dtype=dtype) for v in value)\n    elif isinstance(value, dict):\n        return any(_contains_any_tensor(v, dtype=dtype) for v in value.values())\n    return False\n", "path": "flash/core/data/utils.py"}], "after_files": [{"content": "# Copyright The PyTorch Lightning team.\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport os.path\nimport zipfile\nfrom typing import Any, Type\n\nimport requests\nimport torch\nfrom tqdm.auto import tqdm as tq\n\n\n# Code taken from: https://gist.github.com/ruxi/5d6803c116ec1130d484a4ab8c00c603\n# __author__  = \"github.com/ruxi\"\n# __license__ = \"MIT\"\ndef download_file(url: str, path: str, verbose: bool = False) -> None:\n    \"\"\"\n    Download file with progressbar\n\n    Usage:\n        download_file('http://web4host.net/5MB.zip')\n    \"\"\"\n    if not os.path.exists(path):\n        os.makedirs(path)\n    local_filename = os.path.join(path, url.split('/')[-1])\n    r = requests.get(url, stream=True)\n    file_size = int(r.headers['Content-Length']) if 'Content-Length' in r.headers else 0\n    chunk = 1\n    chunk_size = 1024\n    num_bars = int(file_size / chunk_size)\n    if verbose:\n        print(dict(file_size=file_size))\n        print(dict(num_bars=num_bars))\n\n    if not os.path.exists(local_filename):\n        with open(local_filename, 'wb') as fp:\n            for chunk in tq(\n                r.iter_content(chunk_size=chunk_size),\n                total=num_bars,\n                unit='KB',\n                desc=local_filename,\n                leave=True  # progressbar stays\n            ):\n                fp.write(chunk)  # type: ignore\n\n    if '.zip' in local_filename:\n        if os.path.exists(local_filename):\n            with zipfile.ZipFile(local_filename, 'r') as zip_ref:\n                zip_ref.extractall(path)\n\n\ndef download_data(url: str, path: str = \"data/\") -> None:\n    \"\"\"\n    Downloads data automatically from the given url to the path. Defaults to data/ for the path.\n    Automatically handles .csv, .zip\n\n    Example::\n\n        from flash import download_data\n\n    Args:\n        url: path\n        path: local\n\n    \"\"\"\n    download_file(url, path)\n\n\ndef _contains_any_tensor(value: Any, dtype: Type = torch.Tensor) -> bool:\n    # TODO: we should refactor FlashDatasetFolder to better integrate\n    # with DataPipeline. That way, we wouldn't need this check.\n    # This is because we are running transforms in both places.\n    if isinstance(value, dtype):\n        return True\n    if isinstance(value, (list, tuple)):\n        return any(_contains_any_tensor(v, dtype=dtype) for v in value)\n    elif isinstance(value, dict):\n        return any(_contains_any_tensor(v, dtype=dtype) for v in value.values())\n    return False\n", "path": "flash/core/data/utils.py"}]}