Skip to content

Instantly share code, notes, and snippets.

@4poc
Created February 20, 2011 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 4poc/835763 to your computer and use it in GitHub Desktop.
Save 4poc/835763 to your computer and use it in GitHub Desktop.
pubsub scribble / debug server
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/
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);
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