def METHOD_NAME(self, request):
    data = request.data
    if data is not None and type(data) != str:
        v_files = []
        v_vars = []
        try:
             for(key, value) in list(data.items()):
                 # 'file' type doesn't exist in python3 and we didn't use it. Removed if:
                 v_vars.append((key, value))
        except TypeError:
            systype, value, traceback = sys.exc_info()
            raise TypeError("not a valid non-string sequence or mapping object", traceback)
        if len(v_files) == 0:
            data = ulib.urlencode(v_vars, doseq)
        else:
            boundary, data = self.multipart_encode(v_vars, v_files)
            contenttype = 'multipart/form-data; boundary=%s' % boundary
            if(request.has_header('Content-Type')
               and request.get_header('Content-Type').find('multipart/form-data') != 0):
                print("Replacing %s with %s" % (request.get_header('content-type'), 'multipart/form-data'))
            request.add_unredirected_header('Content-Type', contenttype)
        request.data = bytearray(data, 'latin1')
    return request