<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,8 @@
+== 0.1.1 2008-07-30
+
+* 1 major enhancement:
+	* Added :basic_auth key for options when making a request
+
 == 0.1.0 2008-07-27
 
 * 1 major enhancement:</diff>
      <filename>History.txt</filename>
    </modified>
    <modified>
      <diff>@@ -8,8 +8,8 @@ class Delicious
   base_uri 'https://api.del.icio.us/v1'
   format :xml
   
-  def initialize(user, pass)
-    self.class.basic_auth(user, pass)
+  def initialize(u, p)
+    @auth = {:username =&gt; u, :password =&gt; p}
   end
   
   # query params that filter the posts are:
@@ -18,23 +18,21 @@ class Delicious
   #   url (optional). Filter by this url.
   #   ie: posts(:query =&gt; {:tag =&gt; 'ruby'})
   def posts(options={})
+    options.merge!({:basic_auth =&gt; @auth})
     # get posts and convert to structs so we can do .key instead of ['key'] with results
-    self.class.get('/posts/get', options)['posts']['post'].map { |b| b.to_struct }
+    self.class.get('/posts/get', options)
   end
   
   # query params that filter the posts are:
   #   tag (optional). Filter by this tag.
   #   count (optional). Number of items to retrieve (Default:15, Maximum:100).
   def recent(options={})
-    self.class.get('/posts/recent', options)['posts']['post'].map { |b| b.to_struct }
+    options.merge!({:basic_auth =&gt; @auth})
+    self.class.get('/posts/recent', options)
   end
 end
 
 delicious = Delicious.new(config['username'], config['password'])
-
 pp delicious.posts(:query =&gt; {:tag =&gt; 'ruby'})
-
-puts '', '*' * 50, ''
-
 pp delicious.recent
 </diff>
      <filename>examples/delicious.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,30 +7,24 @@ class Twitter
   include HTTParty
   base_uri 'twitter.com'
   
-  def initialize(user, pass)
-    self.class.basic_auth user, pass
+  def initialize(u, p)
+    @auth = {:username =&gt; u, :password =&gt; p}
   end
   
   # which can be :friends, :user or :public
   # options[:query] can be things like since, since_id, count, etc.
   def timeline(which=:friends, options={})
-    self.class.get(&quot;/statuses/#{which}_timeline.xml&quot;, options)['statuses'].map { |s| s.to_struct }
+    options.merge!({:basic_auth =&gt; @auth})
+    self.class.get(&quot;/statuses/#{which}_timeline.json&quot;, options)
   end
   
   def post(text)
-    self.class.post('/statuses/update.xml', :query =&gt; {:status =&gt; text})['status'].to_struct
+    options = { :query =&gt; {:status =&gt; text}, :basic_auth =&gt; @auth }
+    self.class.post('/statuses/update.json', options)
   end
 end
 
-
 twitter = Twitter.new(config['email'], config['password'])
-
-twitter.timeline.each do |s|
-  puts s.user.name, s.text, &quot;#{s.created_at} #{s.id}&quot;, ''
-end
-
-# twitter.timeline(:friends, :query =&gt; {:since_id =&gt; 868482746}).each do |s|
-#   puts s.user.name, s.text, &quot;#{s.created_at} #{s.id}&quot;, ''
-# end
-# 
+pp twitter.timeline
+# pp twitter.timeline(:friends, :query =&gt; {:since_id =&gt; 868482746})
 # pp twitter.post('this is a test')
\ No newline at end of file</diff>
      <filename>examples/twitter.rb</filename>
    </modified>
    <modified>
      <diff>@@ -28,10 +28,15 @@ module HTTParty
       @base_uri = normalize_base_uri(base_uri)
     end
     
+    # Warning: This is not thread safe most likely and
+    # only works if you use one set of credentials. I
+    # leave it because it is convenient on some occasions.
     def basic_auth(u, p)
       @auth = {:username =&gt; u, :password =&gt; p}
     end
     
+    # Updates the default query string parameters
+    # that should be appended to each request.
     def default_params(h={})
       raise ArgumentError, 'Default params must be a hash' unless h.is_a?(Hash)
       @default_params ||= {}
@@ -83,14 +88,17 @@ module HTTParty
         @http
       end
       
+      # FIXME: this method is doing way to much and needs to be split up
       # options can be any or all of:
-      #   query   =&gt; hash of keys/values to be converted to query string
-      #   body    =&gt; string for raw post data
-      #   headers =&gt; hash of headers to send request with
+      #   query       =&gt; hash of keys/values to be converted to query string
+      #   body        =&gt; string for raw post data
+      #   headers     =&gt; hash of headers to send request with
+      #   basic_auth  =&gt; :username and :password to use as basic http authentication (overrides @auth class instance variable)
       def send_request(method, path, options={})
         raise ArgumentError, 'only get, post, put and delete methods are supported' unless %w[get post put delete].include?(method.to_s)
         raise ArgumentError, ':query must be a hash' if options[:query] &amp;&amp; !options[:query].is_a?(Hash)
         raise ArgumentError, ':headers must be a hash' if options[:headers] &amp;&amp; !options[:headers].is_a?(Hash)
+        raise ArgumentError, ':basic_auth must be a hash' if options[:basic_auth] &amp;&amp; !options[:basic_auth].is_a?(Hash)
         # we always want path that begins with /
         path         = path =~ /^(\/|https?:\/\/)/ ? path : &quot;/#{path}&quot;
         @format    ||= format_from_path(path)
@@ -100,9 +108,11 @@ module HTTParty
         klass        = Net::HTTP.const_get method.to_s.downcase.capitalize
         request      = klass.new(uri.request_uri)
         request.body = options[:body] unless options[:body].blank?
+        basic_auth   = options.delete(:basic_auth) || @auth
         request.initialize_http_header headers.merge(options[:headers] || {})
-        request.basic_auth(@auth[:username], @auth[:password]) if @auth
-        response     = http(uri).start() { |conn| conn.request(request) }
+        # note to self: self, do not put basic auth above headers because it removes basic auth
+        request.basic_auth(basic_auth[:username], basic_auth[:password]) if basic_auth
+        response     = http(uri).request(request)
         parse_response(response.body)
       end
       </diff>
      <filename>lib/httparty.rb</filename>
    </modified>
    <modified>
      <diff>@@ -141,5 +141,11 @@ describe HTTParty do
         Foo.send(:send_request, 'get', '/foo', :headers =&gt; 'string')
       end.should raise_error(ArgumentError)
     end
+    
+    it 'should require that :basic_auth is a hash if present' do
+      lambda do
+        Foo.send(:send_request, 'get', '/foo', :basic_auth =&gt; 'string')
+      end.should raise_error(ArgumentError)
+    end
   end
 end
\ No newline at end of file</diff>
      <filename>spec/httparty_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>9543593d74193ae1ef7a1767a3007dc02c619066</id>
    </parent>
  </parents>
  <author>
    <name>John Nunemaker</name>
    <email>nunemaker@gmail.com</email>
  </author>
  <url>http://github.com/jnunemaker/httparty/commit/3a8ad1da073c5ae61a2687a250cb17bc04f9c7c9</url>
  <id>3a8ad1da073c5ae61a2687a250cb17bc04f9c7c9</id>
  <committed-date>2008-07-30T21:05:36-07:00</committed-date>
  <authored-date>2008-07-30T21:05:36-07:00</authored-date>
  <message>Added :basic_auth as an option key when making a request. [#1 state:resolved]</message>
  <tree>98aa42c63b8a19176c87619ca49ac36b398e4bcb</tree>
  <committer>
    <name>John Nunemaker</name>
    <email>nunemaker@gmail.com</email>
  </committer>
</commit>
