<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/viddler/multipart_params.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,2 @@
 doc
 log/*.log
-test/viddler.yml</diff>
      <filename>.gitignore</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,7 @@ require 'fileutils'
 include FileUtils
 
 require 'rubygems'
-%w[rake hoe newgem rubigen active_support curb].each do |req_gem|
+%w[rake hoe newgem rubigen active_support rest_client mime/types].each do |req_gem|
   begin
     require req_gem
   rescue LoadError</diff>
      <filename>config/requirements.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,13 +4,13 @@ $:.unshift(File.dirname(__FILE__)) unless
 require 'rubygems'
 require 'active_support'
 require 'ostruct'
-require 'curb'
 
 require 'ext/open_struct'
 require 'ext/hash'
 require 'ext/array'
 require 'viddler/api_spec'
 require 'viddler/base'
+require 'viddler/multipart_params'
 require 'viddler/request'
 require 'viddler/video'
 require 'viddler/comment'
@@ -18,4 +18,4 @@ require 'viddler/user'
 
 # Module to encapsule the Viddler API.
 module Viddler
-end
+end
\ No newline at end of file</diff>
      <filename>lib/viddler.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,3 +1,5 @@
+require 'rest_client'
+
 module Viddler
   
   # Raised when response from Viddler contains absolutely no data
@@ -15,14 +17,16 @@ module Viddler
   class Request #:nodoc:
     
     API_URL = 'http://api.viddler.com/rest/v1/'
+    DEFAULT_HEADERS = {:accept =&gt; 'application/xml', :content_type =&gt; 'application/x-www-form-urlencoded'}
   
-    attr_accessor :url, :http_method, :response
-    attr_reader :params
+    attr_accessor :url, :http_method, :response, :body
+    attr_reader :headers, :params
   
     def initialize(http_method, method) #:nodoc:
       @http_method = http_method.to_s
       @url = API_URL
       self.params = {:method =&gt; viddlerize(method)}    
+      self.headers = DEFAULT_HEADERS
     end
     
     # Use this method to setup your request's payload and headers.
@@ -49,35 +53,22 @@ module Viddler
       if block_given?
         set(:params, &amp;block)
       end
-
-      c = Curl::Easy.new(url)
-      c.headers['Accept'] = 'application/xml'
     
       if post? and multipart?
-        c.multipart_form_post = true
-        c.http_post(*build_params)
+        put_multipart_params_into_body
       else
-        c.url = url_with_params
-        c.perform
-      end
-
-      self.response = parse_response(c.body_str)
+        put_params_into_url
+      end    
+      request = RestClient::Request.execute(
+         :method =&gt; http_method, 
+         :url =&gt; url, 
+         :headers =&gt; headers, 
+         :payload =&gt; body
+       )
+       self.response = parse_response(request)
     end
   
     private
-
-    def build_params
-      f = []
-      t = []
-      params.each do |key, value| 
-        if value.is_a? File
-          f &lt;&lt; Curl::PostField.file(key.to_s, value.path, File.basename(value.path))
-        else
-          t &lt;&lt; Curl::PostField.content(key.to_s, value.to_s)
-        end
-      end
-      t + f
-    end
   
     def parse_response(raw_response)
       raise EmptyResponseError if raw_response.blank?
@@ -88,8 +79,14 @@ module Viddler
       response_hash
     end
   
-    def url_with_params
-      self.url + '?' + params.to_query
+    def put_multipart_params_into_body
+      multiparams = MultipartParams.new(params)
+      self.body = multiparams.body
+      self.headers = {:content_type =&gt; multiparams.content_type}
+    end
+  
+    def put_params_into_url
+      self.url = self.url + '?' + params.to_query
     end
   
     def viddlerize(name)
@@ -105,6 +102,11 @@ module Viddler
       @params.update(hash)
     end
   
+    def headers=(hash) #:nodoc:
+      @headers ||= Hash.new
+      @headers.update(hash)
+    end
+  
     def multipart? #:nodoc:
       if params.find{|k,v| v.is_a?(File)} then true else false end
     end</diff>
      <filename>lib/viddler/request.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,2 @@
 require 'test/unit'
-require 'ruby_debug'
 require 'viddler'
-require 'yaml'</diff>
      <filename>test/test_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,27 +1,45 @@
 require File.dirname(__FILE__) + '/test_helper.rb'
 
 class ViddlerTest &lt; Test::Unit::TestCase
-
-  TEST_VIDEO_FILE_PATH  = '/home/petyo/Test/sample.vob'
+  class KeyRequired &lt; Exception
+    def message
+      'In order to run this test, insert working Viddler API key inside API_KEY constant.'
+    end
+  end  
+  
+  class CredentialsRequired &lt; Exception
+    def message
+      'In order to run this test, insert working Viddler username and password inside LOGIN and PASSWORD constants.'
+    end
+  end
+  
+  # In order to run the tests you need a working Viddler account and an API key.
+  API_KEY               = nil
+  LOGIN                 = nil
+  PASSWORD              = nil
+  TEST_VIDEO_FILE_PATH  = '/path/to/video'
   
   def setup
-    config = YAML.load_file File.join(File.dirname(__FILE__), 'viddler.yml') rescue &quot;you need test/viddler.yml, check viddler.yml.example for credentals.&quot;
-    @viddler = Viddler::Base.new(config['api_key'], config['login'], config['password'])
+    raise KeyRequired unless API_KEY
+    @viddler = Viddler::Base.new(API_KEY, LOGIN, PASSWORD)
   end
 
   def test_should_authenticate
+    credentials_required
     @viddler.authenticate
     assert @viddler.authenticated?
   end
   
   def test_should_get_record_token
+    credentials_required
     token = @viddler.get_record_token
     assert_kind_of String, token
   end
   
   def test_should_upload_video
+    credentials_required
     file = File.open(TEST_VIDEO_FILE_PATH)
-    video = @viddler.upload_video(:file =&gt; file, :title =&gt; 'Testing', :description =&gt; 'Bla', :tags =&gt; 'one, two, three', :make_public =&gt; '1')
+    video = @viddler.upload_video(:file =&gt; file, :title =&gt; 'Testing', :description =&gt; 'Bla', :tags =&gt; 'one, two, three')
   end
   
   def test_should_find_profile
@@ -30,6 +48,7 @@ class ViddlerTest &lt; Test::Unit::TestCase
   end
   
   def test_should_update_profile
+    credentials_required
     user = @viddler.update_profile(:first_name =&gt; 'Ilya', 
                                    :last_name =&gt; 'Sabanin', 
                                    :about_me =&gt; 'A guy', 
@@ -41,14 +60,13 @@ class ViddlerTest &lt; Test::Unit::TestCase
   end
   
   def test_should_update_account
+    credentials_required
     assert @viddler.update_account(:show_account =&gt; '0')
   end
   
-=begin
   def test_should_get_video_status
-    assert @viddler.get_video_status('6b0b9af1')
+    assert @viddler.get_video_status('f8605d95')
   end
-=end
   
   def test_should_find_video_by_id
     video = @viddler.find_video_by_id('6b0b9af1')
@@ -80,5 +98,11 @@ class ViddlerTest &lt; Test::Unit::TestCase
     videos = @viddler.find_all_featured_videos
     assert_kind_of Viddler::Video, videos.first
   end
+  
+  private
+  
+  def credentials_required
+    raise CredentialsRequired unless LOGIN and PASSWORD
+  end
 
 end</diff>
      <filename>test/test_viddler.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>test/viddler.yml.sample</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>6ed9839fa0328909cf04c5a05abc127babab99a0</id>
    </parent>
  </parents>
  <author>
    <name>Petyo Ivanov</name>
    <email>underlog@gmail.com</email>
  </author>
  <url>http://github.com/iSabanin/viddler/commit/21737aa5aa8ade11278d6f6ee219b36c611e9a20</url>
  <id>21737aa5aa8ade11278d6f6ee219b36c611e9a20</id>
  <committed-date>2009-04-11T07:56:17-07:00</committed-date>
  <authored-date>2009-04-11T07:56:17-07:00</authored-date>
  <message>Oops, this is not ready for master branch yet.

Revert &quot;Swapped rest-client and homecooked multipart with curb, which uses C bindings to curl... Maybe it will be faster.&quot;

This reverts commit 6ed9839fa0328909cf04c5a05abc127babab99a0.</message>
  <tree>afdff76c86a87824bb8e2c623363a8271bd545f7</tree>
  <committer>
    <name>Petyo Ivanov</name>
    <email>underlog@gmail.com</email>
  </committer>
</commit>
