lib/icloud/session.rb
# Performs a POST request in this session.
Performs a POST request in this session.
Performs a POST request in this session .
def post url, params={}, postdata={}, headers={}
      uri = URI.parse(url)
      p = postdata.to_json
      h = default_headers.merge(headers)
      path = uri.path + "?" + query_string(default_params.merge(params))
      response = http(uri.host, uri.port).post(path, p, h)
      if (response.code.to_i) == 200 && (response.content_type == "text/json")
        hash = JSON.parse(response.body)
      else
        raise StandardError.new(
          "Request:\n"                               +
          "path: #{path}\n"                          +
          "headers: #{h}\n"                          +
          "#{p}\n"                                   +
          "Response:\n"                              +
          "--\n"                                     +
          "Response:\n"                              +
          "status: #{response.code}\n"               +
          "content-type: #{response.content_type}\n" +
          response.body)
      end
      if hash.include?("ChangeSet")
        apply_changeset(hash["ChangeSet"])
      end
      hash
    end
def post url , params = { } , postdata = { } , headers = { } uri = URI . parse ( url ) p = postdata . to_json h = default_headers . merge ( headers ) path = uri . path + "?" + query_string ( default_params . merge ( params ) ) response = http ( uri . host , uri . port ) . post ( path , p , h ) if ( response . code . to_i ) == 200 && ( response . content_type == "text/json" ) hash = JSON . parse ( response . body ) else raise StandardError . new ( "Request:\n" + "path: #{path}\n" + "headers: #{h}\n" + "#{p}\n" + "Response:\n" + "--\n" + "Response:\n" + "status: #{response.code}\n" + "content-type: #{response.content_type}\n" + response . body ) end if hash . include? ( "ChangeSet" ) apply_changeset ( hash [ "ChangeSet" ] ) end hash end
Performs a POST request in this session.
Performs a POST request in this session .
# If this response contains a changeset, apply it.
url
params
postdata
headers