'Issue a request, and expect a redirect, and then submit the data to
the redirected location. This is used for create, write, etc.
Returns the response from the redirected request.'

def _invoke_with_redirect(self, method, path, params=None, data=None):

    next_url = None
    try:
        self._root.invoke(method, path, params)
    except WebHdfsException as ex:
        next_url = self._get_redirect_url(ex)
    if (next_url is None):
        raise WebHdfsException((_("Failed    to    create    '%s'.    HDFS    did    not    return    a    redirect") % path))
    client = self._make_client(next_url, self.security_enabled, self.ssl_cert_ca_verify)
    client._session = self._client._session
    headers = {'Content-Type': 'application/octet-stream'}
    return resource.Resource(client).invoke(method, data=data, headers=headers)
