labpack/parsing/flask.py
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': ''
    }

# automatically add header and query field data
    request_details['headers'].update(**request_object.headers)
    for key in request_object.args.keys():
        request_details['params'][key] = request_object.args.get(key)

# retrieve session details
    if session_object:
        request_details['session'].update(**session_object)

# add data based upon type
    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

# TODO: handle non-json data parsing (such as by mimetype and request.files)
# TODO: check content type against buffer values
# TODO: status code and error handling

    return request_details

        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
    
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
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
def extract_request_details(request_object, session_object=None):
    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
def extract_request_details ( request_object , session_object = None ) : 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
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
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
'''
        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
    ''' # automatically add header and query field data
 # retrieve session details
 # add data based upon type
 # TODO: handle non-json data parsing (such as by mimetype and request.files)
 # TODO: check content type against buffer values
 # TODO: status code and error handling

dictionary with request details
dictionary with request details
request_object
request object generated by flask from request route
request object generated by flask from request route
session_object
session object generated by flask from client cookie
session object generated by flask from client cookie