Class: Net::DAV::CurlHandler

Inherits:
NetHttpHandler show all
Defined in:
lib/net/dav.rb

Constant Summary

Constants inherited from NetHttpHandler

NetHttpHandler::CNONCE

Instance Attribute Summary

Attributes inherited from NetHttpHandler

#disable_basic_auth, #pass, #user

Instance Method Summary collapse

Methods inherited from NetHttpHandler

#clone_req, #digest_auth, #handle_request, #initialize, #open_timeout, #open_timeout=, #read_timeout, #read_timeout=, #request, #request_sending_body, #request_sending_stream, #start

Constructor Details

This class inherits a constructor from Net::DAV::NetHttpHandler

Instance Method Details

#make_curlObject



238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/net/dav.rb', line 238

def make_curl
  unless @curl
    @curl = Curl::Easy.new
    @curl.timeout = @http.read_timeout
    @curl.follow_location = true
    @curl.max_redirects = MAX_REDIRECTS
    if disable_basic_auth
      @curl.http_auth_types = Curl::CURLAUTH_DIGEST
    end
  end
  @curl
end

#request_returning_body(verb, path, headers) ⇒ Object



251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/net/dav.rb', line 251

def request_returning_body(verb, path, headers)
  raise "unkown returning_body verb #{verb}" unless verb == :get
  url = @uri.merge(path)
  curl = make_curl
  curl.url = url.to_s
  headers.each_pair { |key, value| curl.headers[key] = value } if headers
  if (@user)
    curl.userpwd = "#{@user}:#{@pass}"
  else
    curl.userpwd = nil
  end
  res = nil
  if block_given?
    curl.on_body do |frag|
      yield frag
      frag.length
    end
  end
  curl.perform
  unless curl.response_code >= 200 && curl.response_code < 300
    header_block = curl.header_str.split(/\r?\n\r?\n/)[-1]
    msg = header_block.split(/\r?\n/)[0]
    msg.gsub!(/^HTTP\/\d+.\d+ /, '')
    raise Net::HTTPError.new(msg, nil)
  end
  curl.body_str
end

#verify_callback=(callback) ⇒ Object



225
226
227
228
229
# File 'lib/net/dav.rb', line 225

def verify_callback=(callback)
  super
  curl = make_curl
  $stderr.puts "verify_callback not implemented in Curl::Easy"
end

#verify_server=(value) ⇒ Object



231
232
233
234
235
236
# File 'lib/net/dav.rb', line 231

def verify_server=(value)
  super
  curl = make_curl
  curl.ssl_verify_peer = value
  curl.ssl_verify_host = value
end