Created
February 20, 2011 06:13
-
-
Save 4poc/835763 to your computer and use it in GitHub Desktop.
pubsub scribble / debug server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protocol specification: http://pubsubhubbub.googlecode.com/svn/trunk/pubsubhubbub-core-0.3.html | |
test feed: http://apubtest.wordpress.com/feed/ (atom) | |
hub: <atom:link rel='hub' href='http://apubtest.wordpress.com/?pushpress=hub'/> | |
-> http://apubtest.wordpress.com/?pushpress=hub | |
topic/self: <atom:link href="http://apubtest.wordpress.com/feed/" rel="self" type="application/rss+xml" /> | |
-> http://apubtest.wordpress.com/feed/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require('http'), | |
util = require('util'); | |
http.createServer(function (request, response) { | |
var challenge = null; | |
util.debug('\n\n--- '+unescape(request.url)); | |
for(var key in request.headers) { | |
util.debug(key+': '+request.headers[key]); | |
} | |
var post_data = ''; | |
request.on('data', function(data) { | |
post_data += data; | |
}); | |
request.on('end', function() { | |
util.debug(unescape(post_data)+'\n\n'); | |
var challenge_match; | |
if((challenge_match = request.url.match(/hub.challenge=([^&]+)$/i))) { | |
challenge = challenge_match[1]; | |
} | |
response.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'}); | |
response.end(challenge || 'oki.'); | |
}); | |
}).listen(8998); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Subscribe: | |
curl -i -d "hub.callback=http://<SERVER-HOST/IP>:8998/push&hub.mode=subscribe&hub.topic=http://apubtest.wordpress.com/feed/&hub.verify=async" http://apubtest.wordpress.com/?pushpress=hub | |
Unsubscribe: | |
curl -i -d "hub.callback=http://<SERVER-HOST/IP>:8998/push&hub.mode=unsubscribe&hub.topic=http://apubtest.wordpress.com/feed/&hub.verify=async" http://apubtest.wordpress.com/?pushpress=hub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment