def http_request(self, request):
        try:
            data = request.get_data()
        except AttributeError:
            data = request.data
        if data is not None and type(data) != str:
            v_files = []
            v_vars = []
            try:
                for(key, value) in list(data.items()):
                    if hasattr(value, 'read'):
                        v_files.append((key, value))
                    else:
                        v_vars.append((key, value))
            except TypeError:
                raise TypeError
            if len(v_files) == 0:
                data = urllib.parse.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
                ):
                    six.print_(
                        "Replacing %s with %s" % (
                            request.get_header('content-type'),
                            'multipart/form-data'
                        )
                    )
                request.add_unredirected_header('Content-Type', contenttype)
            try:
                request.add_data(data)
            except AttributeError:
                request.data = data

        return request
dataset/ETHPy150Open datadesk/python-documentcloud/documentcloud/MultipartPostHandler.py/MultipartPostHandler.http_request/original