Weired behaviour (sometimes) on 401 response

So I am writing tests for my flask app at the moment and have great difficulty testing 401 UNAUTHORIZED responses as requests seems to not be able to handle them (sometimes it works interestingly [seems to be quite random though]). I am trying to access a flask webServer without a required jwt token. All browsers and rest clients I tested seem to work perfectly fine, requests for python 3 doesn't however. Python2 requests seems to not have a problem either.

I have checked through wireshark, and all packets are send just as they should.

## Expected Result

```
401
{'Content-Type': 'application/json', 'Content-Length': '30', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Headers': '*', 'Access-Control-Allow-Methods': '*', 'Access-Control-Max-Age': '31540000', 'Server': 'Werkzeug/0.16.0 Python/3.8.0', 'Date': 'Fri, 19 Jun 2020 16:49:11 GMT'}
{
  "msg": "TOKEN_REQUIRED"
}
```

## Actual Result

```
Traceback (most recent call last):
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 665, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 416, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1322, in getresponse
    response.begin()
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 327, in begin
    self.headers = self.msg = parse_headers(self.fp)
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 212, in parse_headers
    line = fp.readline(_MAXLINE + 1)
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\socket.py", line 669, in readinto
    return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py", line 439, in send
    resp = conn.urlopen(
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 719, in urlopen
    retries = retries.increment(
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\util\retry.py", line 400, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\packages\six.py", line 734, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 665, in urlopen
    httplib_response = self._make_request(
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 421, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\site-packages\urllib3\connectionpool.py", line 416, in _make_request
    httplib_response = conn.getresponse()
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 1322, in getresponse
    response.begin()
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 327, in begin
    self.headers = self.msg = parse_headers(self.fp)
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\http\client.py", line 212, in parse_headers
    line = fp.readline(_MAXLINE + 1)
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\socket.py", line 669, in readinto
    return self._sock.recv_into(b)
urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetError(10054, 
'An existing connection was forcibly closed by the remote host', None, 10054, None))  

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File ".\test2.py", line 7, in <module>
    req = requests.post(url, headers=headers, data=body)
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py", line 119, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "C:\Users\Someone\AppData\Local\Programs\Python\Python38\lib\site-packages\requests\adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
```

OR on linux

```
api/tests/test_2account.py:25: in checkResponse
    assert response.json()["msg"] == "TOKEN_REQUIRED"
/home/coronon/.local/lib/python3.8/site-packages/requests/models.py:898: in json
    return complexjson.loads(self.text, **kwargs)
/usr/lib/python3.8/json/__init__.py:357: in loads
    return _default_decoder.decode(s)
/usr/lib/python3.8/json/decoder.py:337: in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <json.decoder.JSONDecoder object at 0x7fc23da9edf0>, s = '', idx = 0

    def raw_decode(self, s, idx=0):
        """Decode a JSON document from ``s`` (a ``str`` beginning with
        a JSON document) and return a 2-tuple of the Python
        representation and the index in ``s`` where the document ended.
    
        This can be used to decode a JSON document from a string that may
        have extraneous data at the end.
    
        """
        try:
            obj, end = self.scan_once(s, idx)
        except StopIteration as err:
>           raise JSONDecodeError("Expecting value", s, err.value) from None
E           json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
```

## Reproduction Steps

```python
import requests

url = 'http://localhost:5000/account/updatebaseinfo'
headers = {'Content-Type': 'application/json','user-agent': 'advanced-rest-client','accept': '*/*','content-length': '126'}
body = """{"email": "test.updatebaseinfo@pytest.com", "firstname": "Test-Testi", "lastname": "Someone", "gender": 1, "graduated": 2000}"""

req = requests.post(url, headers=headers, data=body)

print(req.status_code)
print(req.headers)
print(req.text)

```

# Flask Webserver route:

I am using jwt from [flask_jwt_extended](https://flask-jwt-extended.readthedocs.io/en/stable/)

```py
@mod_account.route("/updatebaseinfo", methods=['POST'])
@jwt_required
def updatebaseinfo() -> Tuple[Response, int]:
...
```

How I handle token missing on the backend:

```py
@jwt.unauthorized_loader
def unauthorized_loader(error: str) -> Tuple[Response, int]:
    """Handle response on missing token

    Arguments:
        error {str} -- Why token could not be found

    Returns:
        Response -- Response send to client
    """
    return jsonify({'msg': 'TOKEN_REQUIRED'}), 401
```

## System Information

```
{
  "chardet": {
    "version": "3.0.4"
  },
  "cryptography": {
    "version": "2.8"
  },
  "idna": {
    "version": "2.8"
  },
  "implementation": {
    "name": "CPython",
    "version": "3.8.0"
  },
  "platform": {
    "release": "10",
    "system": "Windows"
  },
  "pyOpenSSL": {
    "openssl_version": "1010104f",
    "version": "19.1.0"
  },
  "requests": {
    "version": "2.24.0"
  },
  "system_ssl": {
    "version": "1010104f"
  },
  "urllib3": {
    "version": "1.25.6"
  },
  "using_pyopenssl": true
}
```


this doesn't seem to be an issue with requests, rather an issue with your webserver.