def update_resource(uri, r, content_type)
      clear
      uri = URI.parse(uri)
      @req = Net::HTTP::Put.new uri.request_uri
      @req['Content-Type'] = content_type
      cache = @cache.get(uri.to_s)
      unless cache.nil?
        @req['If-Not-Modified-Since'] = cache.last_modofied unless cache.last_modified.nil?
        @req['If-Match'] = cache.etag unless cache.etag.nil?
      end
      set_common_info(@req)
      @req.body = r
      @http_class.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
        @res = http.request(@req)
        case @res
          when Net::HTTPSuccess
            #warn "Bad Status Code: #{@res.code}" unless @res.class == Net::HTTPOK || @res.class == Net::HTTPNoContent
            unless @res.body.nil?
              @rc = Atom::MediaType::ENTRY.is_a?(@res['Content-Type']) ? Atom::Entry.new(:stream => @res.body) : @res.body
              @cache.put uri.to_s, {
                :rc            => @rc,
                :etag          => @res['ETag'],
                :last_modified => @res['Last-Modified'] }
            end
          else
            raise RequestError, "Failed to update resource. #{@res.code}"
        end
      end
    end
def update_resource(uri, r, content_type)
      clear
      uri = URI.parse(uri)
      @req = Net::HTTP::Put.new uri.request_uri
      @req['Content-Type'] = content_type
      cache = @cache.get(uri.to_s)
      unless cache.nil?
        @req['If-Not-Modified-Since'] = cache.last_modofied unless cache.last_modified.nil?
        @req['If-Match'] = cache.etag unless cache.etag.nil?
      end
      set_common_info(@req)
      @req.body = r
      @http_class.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
        @res = http.request(@req)
        case @res
          when Net::HTTPSuccess
            #warn "Bad Status Code: #{@res.code}" unless @res.class == Net::HTTPOK || @res.class == Net::HTTPNoContent
            unless @res.body.nil?
              @rc = Atom::MediaType::ENTRY.is_a?(@res['Content-Type']) ? Atom::Entry.new(:stream => @res.body) : @res.body
              @cache.put uri.to_s, {
                :rc            => @rc,
                :etag          => @res['ETag'],
                :last_modified => @res['Last-Modified'] }
            end
          else
            raise RequestError, "Failed to update resource. #{@res.code}"
        end
      end
    end
updated resources(entry or media)