class Patron::Session

server. This is the primary API for Patron.
This class represents multiple request/response transactions with an HTTP

def copy(url, dest, headers = {})

Sends a WebDAV COPY request to the specified +url+.
def copy(url, dest, headers = {})
  headers['Destination'] = dest
  request(:copy, url, headers)
end

def delete(url, headers = {})

As #get but sends an HTTP DELETE request.
def delete(url, headers = {})
  request(:delete, url, headers)
end

def get(url, headers = {})

Response object.
of the +headers+ instance variable. The results are returned in a
to the +url+ parameter. Any custom headers are merged with the contents
specified headers. If the +base_url+ varaible is set then it is prepended
Retrieve the contents of the specified +url+ optionally sending the
def get(url, headers = {})
  request(:get, url, headers)
end

def get_file(url, filename, headers = {})

content at the URL is downloaded directly into the specified file.
Retrieve the contents of the specified +url+ as with #get, but the
def get_file(url, filename, headers = {})
  request(:get, url, headers, :file => filename)
end

def handle_cookies(file = nil)

must be readable and writable. Calling multiple times will add more files.
If file is nil they will be stored in memory. Otherwise the +file+
Makes this session handle cookies and store them in in +file+.
def handle_cookies(file = nil)
  if file
    path = Pathname(file).expand_path
    unless File.exists?(file) and File.writable?(path.dirname)
      raise ArgumentError, "Can't create file #{path} (permission error)"
    end
    unless File.readable?(file) or File.writable?(path)
      raise ArgumentError, "Cant read or write file #{path} (permission error)"
    end
  end
  enable_cookie_session(path.to_s)
  self
end

def head(url, headers = {})

As #get but sends an HTTP HEAD request.
def head(url, headers = {})
  request(:head, url, headers)
end

def initialize

Create a new Session object.
def initialize
  ext_initialize
  @headers = {}
  @timeout = 5
  @connect_timeout = 1000
  @max_redirects = -1
  @auth_type = :basic
end

def post(url, data, headers = {})

must be a string.
Uploads the passed +data+ to the specified +url+ using HTTP POST. +data+
def post(url, data, headers = {})
  request(:post, url, headers, :data => data)
end

def post_file(url, filename, headers = {})

Uploads the contents of a file to the specified +url+ using HTTP POST.
def post_file(url, filename, headers = {})
  request(:post, url, headers, :file => filename)
end     

def put(url, data, headers = {})

must be a string.
Uploads the passed +data+ to the specified +url+ using HTTP PUT. +data+
def put(url, data, headers = {})
  request(:put, url, headers, :data => data)
end

def put_file(url, filename, headers = {})

Uploads the contents of a file to the specified +url+ using HTTP PUT.
def put_file(url, filename, headers = {})
  request(:put, url, headers, :file => filename)
end

def request(action, url, headers, options = {})

Send an HTTP request to the specified +url+.
def request(action, url, headers, options = {})
  req = Request.new
  req.action = action
  req.timeout = self.timeout
  req.connect_timeout = self.connect_timeout
  req.max_redirects = self.max_redirects
  req.headers = self.headers.merge(headers)
  req.username = self.username
  req.password = self.password
  req.upload_data = options[:data]
  req.file_name = options[:file]
  req.proxy = proxy
  req.auth_type = auth_type
  req.url = self.base_url.to_s + url.to_s
  raise ArgumentError, "Empty URL" if req.url.empty?
  handle_request(req)
end