<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -8,6 +8,8 @@ module EventMachine
   class PubSubHubbub
     include EventMachine::Deferrable
 
+    HEADERS = {&quot;User-Agent&quot; =&gt; &quot;PubSubHubbub Ruby&quot;, &quot;Content-Type&quot; =&gt; &quot;application/x-www-form-urlencoded&quot;}
+
     def initialize(hub)
       @hub = hub.kind_of?(URI) ? hub : URI::parse(hub)
     end
@@ -17,7 +19,7 @@ module EventMachine
         {'hub.url' =&gt; feed, 'hub.mode' =&gt; 'publish'}.to_params
       end.join(&quot;&amp;&quot;)
 
-      r = EventMachine::HttpRequest.new(@hub).post :body =&gt; data
+      r = EventMachine::HttpRequest.new(@hub).post :body =&gt; data, :head =&gt; HEADERS
       r.callback { 
         if r.response_header.status == 204
           succeed r
@@ -30,52 +32,29 @@ module EventMachine
       r
     end
 
-    ##
-    # This will work only if ythe callback URL supports confirmation.
-    def subscribe(feed, callback, options = {})
-      options['hub.verify'] ||= &quot;sync&quot;
-      
-      params = {'hub.topic' =&gt; feed, 'hub.mode' =&gt; 'subscribe', 'hub.callback' =&gt; callback}.merge(options).to_params
+     # These command will work only if the callback URL supports confirmation.
+    def subscribe(feed, callback, options = {});   command('subscribe', feed, callback, options);   end
+    def unsubscribe(feed, callback, options = {}); command('unsubscribe', feed, callback, options); end
 
-      r = EventMachine::HttpRequest.new(@hub).post :body =&gt; params, :head =&gt; {&quot;User-Agent&quot; =&gt; &quot;PubSubHubbub Ruby&quot;, &quot;Content-Type&quot; =&gt; &quot;application/x-www-form-urlencoded&quot;, &quot;Content-Length&quot; =&gt; params.size }
-      
-      r.callback { 
-        if r.response_header.status == 204
-          succeed r
-        else
-          fail r
-        end
-      }
-      
-      r.errback { 
-        fail
-      }
-      r
-    end
+    private
     
-    ##
-    # This will work only if ythe callback URL supports confirmation.
-    def unsubscribe(feed, callback, options = {})
+    def command(cmd, feed, callback, options)
       options['hub.verify'] ||= &quot;sync&quot;
-      
-      params = {'hub.topic' =&gt; feed, 'hub.mode' =&gt; 'unsubscribe', 'hub.callback' =&gt; callback}.merge(options).to_params 
-      
-      r = EventMachine::HttpRequest.new(@hub).post :body =&gt; params, :head =&gt; {&quot;User-Agent&quot; =&gt; &quot;PubSubHubbub Ruby&quot;, &quot;Content-Type&quot; =&gt; &quot;application/x-www-form-urlencoded&quot;, &quot;Content-Length&quot; =&gt; params.size }
-      
-      r.callback { 
+
+      params = {'hub.topic' =&gt; feed, 'hub.mode' =&gt; cmd, 'hub.callback' =&gt; callback}.merge(options).to_params
+      r = EventMachine::HttpRequest.new(@hub).post :body =&gt; params, :head =&gt; HEADERS
+
+      r.callback {
         if r.response_header.status == 204
           succeed r
         else
           fail r
         end
       }
-      
-      r.errback { 
-        fail
-      }
+
+      r.errback { fail }
       r
     end
-    
-  end
-end
 
+  end
+end
\ No newline at end of file</diff>
      <filename>lib/pubsubhubbub/client.rb</filename>
    </modified>
    <modified>
      <diff>@@ -14,7 +14,7 @@ describe EventMachine::PubSubHubbub do
     EventMachine.run {
       pub = EventMachine::PubSubHubbub.new('http://pubsubhubbub.appspot.com/publish').publish &quot;http://www.test.com/&quot;
 
-      pub.errback { fail }
+      pub.errback { failed }
       pub.callback {
         pub.response_header.status.should == 204
         EventMachine.stop
@@ -27,7 +27,7 @@ describe EventMachine::PubSubHubbub do
       feeds = ['http://www.test.com', 'http://www.test.com/2']
       pub = EventMachine::PubSubHubbub.new('http://pubsubhubbub.appspot.com/publish').publish feeds
 
-      pub.errback { fail }
+      pub.errback { failed }
       pub.callback {
         pub.response_header.status.should == 204
         EventMachine.stop
@@ -39,7 +39,7 @@ describe EventMachine::PubSubHubbub do
     EventMachine.run {
       sub = EventMachine::PubSubHubbub.new('http://pubsubhubbub.appspot.com/').subscribe &quot;http://blog.superfeedr.com/atom.xml&quot;, &quot;http://superfeedr.com/hubbub&quot;, {}
       
-      sub.errback { fail }
+      sub.errback { failed }
       sub.callback {
         sub.response_header.status.should == 204
         EventMachine.stop
@@ -51,7 +51,7 @@ describe EventMachine::PubSubHubbub do
     EventMachine.run {
       sub = EventMachine::PubSubHubbub.new('http://pubsubhubbub.appspot.com/').unsubscribe &quot;http://blog.superfeedr.com/atom.xml&quot;, &quot;http://superfeedr.com/hubbub&quot;, {}
       
-      sub.errback { fail }
+      sub.errback { failed }
       sub.callback {
         sub.response_header.status.should == 204
         EventMachine.stop</diff>
      <filename>test/test_client.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>05c7345ad52cd2252657aa334528a6efc7788928</id>
    </parent>
  </parents>
  <author>
    <name>Ilya Grigorik</name>
    <email>ilya@igvita.com</email>
  </author>
  <url>http://github.com/igrigorik/PubSubHubbub/commit/216fafd6cae3b6939fe70433f26bbcbea3920d48</url>
  <id>216fafd6cae3b6939fe70433f26bbcbea3920d48</id>
  <committed-date>2009-07-26T11:49:38-07:00</committed-date>
  <authored-date>2009-07-26T11:49:38-07:00</authored-date>
  <message>refactor subscribe/unsubscribe</message>
  <tree>16c212cc995807ad79111fc7245d2412d3d1f276</tree>
  <committer>
    <name>Ilya Grigorik</name>
    <email>ilya@igvita.com</email>
  </committer>
</commit>
