def extract_request_details(request_object, session_object=None):
    """
        a method for extracting request details from request and session objects

        NOTE:   method is also a placeholder funnel for future validation
                processes, request logging, request context building and
                counter-measures for the nasty web

    :param request_object: request object generated by flask from request route
    :param session_object: session object generated by flask from client cookie
    :return: dictionary with request details
    """
    request_details = {'error': '', 'status': 'ok', 'code': 200, 'method':
        request_object.method, 'session': {}, 'root': request_object.
        url_root, 'route': request_object.path, 'headers': {}, 'form': {},
        'params': {}, 'json': {}, 'data': ''}
    request_details['headers'].update(**request_object.headers)
    for key in request_object.args.keys():
        request_details['params'][key] = request_object.args.get(key)
    if session_object:
        request_details['session'].update(**session_object)
    if request_object.is_json:
        try:
            json_details = request_object.get_json(silent=True)
            if isinstance(json_details, dict):
                request_details['json'] = json_details
        except:
            pass
    else:
        try:
            from base64 import b64encode
            request_details['data'] = b64encode(request_object.data).decode()
        except:
            pass
        try:
            for key, value in request_object.form.items():
                request_details['form'][key] = value
        except:
            pass
    return request_details
