def _postTo(self, callbacks, service, nodeIdentifier, payload=None, contentType=None, eventType=None, redirectURI=None): if not callbacks: return postdata = None nodeURI = getXMPPURI(service, nodeIdentifier) headers = {'Referer': nodeURI.encode('utf-8'), 'PubSub-Service': service.full().encode('utf-8')} if payload: postdata = payload.toXml().encode('utf-8') if contentType: headers['Content-Type'] = "%s;charset=utf-8" % contentType if eventType: headers['Event'] = eventType if redirectURI: headers['Link'] = '<%s>; rel=alternate' % ( redirectURI.encode('utf-8'), ) def postNotification(callbackURI): f = getPageWithFactory(str(callbackURI), method='POST', postdata=postdata, headers=headers) d = f.deferred d.addErrback(log.err) for callbackURI in callbacks: reactor.callLater(0, postNotification, callbackURI)
def _postTo(self, callbacks, service, nodeIdentifier, payload=None, contentType=None, eventType=None, redirectURI=None): if not callbacks: return postdata = None nodeURI = getXMPPURI(service, nodeIdentifier) headers = { 'Referer': nodeURI.encode('utf-8'), 'PubSub-Service': service.full().encode('utf-8') } if payload: postdata = payload.toXml().encode('utf-8') if contentType: headers['Content-Type'] = "%s;charset=utf-8" % contentType if eventType: headers['Event'] = eventType if redirectURI: headers['Link'] = '<%s>; rel=alternate' % ( redirectURI.encode('utf-8'), ) def postNotification(callbackURI): f = getPageWithFactory(str(callbackURI), method='POST', postdata=postdata, headers=headers) d = f.deferred d.addErrback(log.err) for callbackURI in callbacks: reactor.callLater(0, postNotification, callbackURI)
def getXMPPURI(service, nodeIdentifier): """ Construct an XMPP URI from a service JID and node identifier. """ return "xmpp:%s?;node=%s" % (service.full(), nodeIdentifier or '')