<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -11,11 +11,18 @@ Copyright (c) 2009 Digg Inc. All rights reserved.
 
 import os
 import base64
+import random
+import md5
+from time import time
 
 class MXHRStreamer(object):
     &quot;&quot;&quot;Simple class that handles streaming multipart payloads&quot;&quot;&quot;
     def __init__(self):
         self.payloads = []
+        self.boundary = &quot;_%d-%s&quot; % (time(), md5.new(str(random.randint(0, 2**32))).hexdigest())
+        
+    def get_boundary(self):
+        return self.boundary
         
     def add_image(self, image, content_type):
         encoded = base64.b64encode(image)
@@ -33,11 +40,11 @@ class MXHRStreamer(object):
     def stream(self):
         stream = &quot;&quot;
         for payload, content_type in self.payloads:
-            stream += &quot;--|||\n&quot;
+            stream += &quot;--%s\n&quot; % self.get_boundary() 
             stream += &quot;Content-Type: %s\n&quot; % content_type
-            stream += payload
+            stream += &quot;%s\n&quot; % payload
             
-        stream += &quot;--|||--&quot;
+        stream += &quot;--%s--&quot; % self.get_boundary() 
         self.payloads = []
         
         return stream
@@ -68,7 +75,7 @@ def main():
     
     &quot;&quot;&quot;
     print &quot;MIME-Version: 1.0&quot;
-    print &quot;Content-Type: multipart/mixed; boundary=\&quot;|||\&quot;&quot;
+    print &quot;Content-Type: multipart/mixed; boundary=\&quot;%s\&quot;\n&quot; % streamer.get_boundary()
     print streamer.stream(), 
     
 if __name__ == '__main__':</diff>
      <filename>examples/Python/demo.py</filename>
    </modified>
    <modified>
      <diff>@@ -9,14 +9,21 @@ Copyright (c) 2009 Digg Inc. All rights reserved.
 =end
 
 require 'base64'
+require 'digest'
 
 class MXHRStreamer
     def initialize
+        srand()
         @payloads = []
+        @boundary = &quot;_%d-%s&quot; % [ Time.now.to_i, Digest::MD5.hexdigest(rand(2**32).to_s) ]
+    end
+
+    def get_boundary
+        return @boundary
     end
 
     def add_image(image, content_type)
-        encoded = Base64.b64encode(image)
+        encoded = Base64.encode64(image)
         self.add_payload(encoded, content_type)
     end
 
@@ -35,11 +42,11 @@ class MXHRStreamer
     def stream
         stream = &quot;&quot;
         @payloads.each { |payload, content_type|
-            stream += &quot;--|||\n&quot;
-            stream += &quot;Content-Type: &quot; + content_type + &quot;\n&quot;
-            stream += payload
+            stream += &quot;--%s\n&quot; % self.get_boundary() 
+            stream += &quot;Content-Type: %s\n\n&quot; % content_type 
+            stream += &quot;%s\n&quot; % payload
         }
-        stream += &quot;--|||--&quot;
+        stream += &quot;--&quot; + self.get_boundary() + &quot;--&quot;
         @payloads.clear
 
         return stream
@@ -65,6 +72,6 @@ javascript = &quot;console.log('huuurrrr');/* fake data */&quot;
 # This is just an example, so remember, you need to set the MIME-Version and 
 # Content-Type headers in your favorite framework
 
-puts &quot;MIME-Version: 1.0&quot;
-puts &quot;Content-Type: multipart/mixed; boundary=\&quot;|||\&quot;&quot;
+puts &quot;MIME-Version: 1.0\n&quot;
+puts &quot;Content-Type: multipart/mixed; boundary=\&quot;&quot; + streamer.get_boundary() + &quot;\&quot;\n\n&quot;
 puts streamer.stream()</diff>
      <filename>examples/Ruby/demo.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0053faec5e01ff072003226f743d2bd1b0225ea6</id>
    </parent>
  </parents>
  <author>
    <name>Arsenio Santos</name>
    <email>arsenio@gmail.com</email>
  </author>
  <url>http://github.com/digg/stream/commit/bcee05d8640918938eb1ea74a73fd09832aac5d9</url>
  <id>bcee05d8640918938eb1ea74a73fd09832aac5d9</id>
  <committed-date>2009-04-10T14:06:06-07:00</committed-date>
  <authored-date>2009-04-10T14:06:06-07:00</authored-date>
  <message>Using real boundaries for Python and Ruby examples (with a coupla bugfixes along the way)</message>
  <tree>e0354e44f2522fb1adfa615383c3f67c36d3a613</tree>
  <committer>
    <name>Arsenio Santos</name>
    <email>arsenio@gmail.com</email>
  </committer>
</commit>
