Ref : https://github.com/python/cpython/pull/25174

https://github.com/localstack/localstack/blob/5a5edcd9d9ccbd6a56f23d71e3a1131b8c814996/localstack/utils/common.py#L324
if iter_length >= iter_limit:
                    LOG.debug('Written %s bytes (total %s) to %s' % (iter_length, total, path))
                    iter_length = 0
            f.flush()
            os.fsync(f)
        if os.path.getsize(path) == 0:
            LOG.warning('Zero bytes downloaded from %s, retrying' % url)
            download(url, path, verify_ssl)
            return
        LOG.debug('Done downloading %s, response code %s, total bytes %d' % (url, r.status_code, total))
    finally:
        r.close()
        s.close()
def parse_request_data(method, path, data=None, headers={}):
    """ Extract request data either from query string (for GET) or request body (for POST). """
    result = {}
    headers = headers or {}
    content_type = headers.get('Content-Type', '')
    if method in ['POST', 'PUT', 'PATCH'] and (not content_type or 'form-' in content_type):
        
        try:
            result = parse_qs(to_str(data or ''))
        except Exception:
            pass  
    if not result:
        parsed_path = urlparse(path)
        result = parse_qs(parsed_path.query)
    result = dict([(k, v[0]) for k, v in result.items()])
    return result
def first_char_to_lower(s):