def create_resource(uri, r, content_type, slug=nil)
      clear
      uri = URI.parse(uri)
      #service = @service_info.get(uri.to_s)
      #unless service.accepts_media_type(content_type)
      #  raise UnsupportedMediaTypeError, "Unsupported media type: #{content_type}."
      #end
      @req = Net::HTTP::Post.new uri.request_uri
      @req['Content-Type'] = content_type
      @req['Slug'] = URI.encode(URI.decode(slug)) unless slug.nil?
      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::HTTPCreated
            #warn "Bad Content Type: #{@res['Content-Type']}" unless Atom::MediaType::ENTRY.is_a?(@res['Content-Type'])
            if @res['Location'].nil?
              raise ResponseError, "No Location"
            end
            unless @res.body.nil?
              @rc = Atom::Entry.new :stream => @res.body
              @cache.put uri.to_s, {
                :rc            => @rc,
                :last_modified => @res['Last-Modified'],
                :etag          => @res['ETag']
              }
            end
          else
            error_message = @res.body.nil?? "#{@res.code}" : "#{@res.code} / #{@res.body}"
            raise RequestError, "Failed to create resource. #{error_message}"
        end
      end
    end
def create_resource(uri, r, content_type, slug=nil)
      clear
      uri = URI.parse(uri)
      #service = @service_info.get(uri.to_s)
      #unless service.accepts_media_type(content_type)
      #  raise UnsupportedMediaTypeError, "Unsupported media type: #{content_type}."
      #end
      @req = Net::HTTP::Post.new uri.request_uri
      @req['Content-Type'] = content_type
      @req['Slug'] = URI.encode(URI.decode(slug)) unless slug.nil?
      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::HTTPCreated
            #warn "Bad Content Type: #{@res['Content-Type']}" unless Atom::MediaType::ENTRY.is_a?(@res['Content-Type'])
            if @res['Location'].nil?
              raise ResponseError, "No Location"
            end
            unless @res.body.nil?
              @rc = Atom::Entry.new :stream => @res.body
              @cache.put uri.to_s, {
                :rc            => @rc,
                :last_modified => @res['Last-Modified'],
                :etag          => @res['ETag']
              }
            end
          else
            error_message = @res.body.nil?? "#{@res.code}" : "#{@res.code} / #{@res.body}"
            raise RequestError, "Failed to create resource. #{error_message}"
        end
      end
    end
Create new resources(entry or media)