Class: RExchange::ExchangeRequest
- Inherits:
-
Net::HTTPRequest
- Object
- Net::HTTPRequest
- RExchange::ExchangeRequest
- Defined in:
- lib/rexchange/exchange_request.rb
Overview
Exchange Server’s WebDAV interface is non-standard, so we create this simple wrapper to extend the ‘net/http’ library and add the request methods we need.
Direct Known Subclasses
Constant Summary collapse
- REQUEST_HAS_BODY =
true
- RESPONSE_HAS_BODY =
true
Class Method Summary collapse
Class Method Details
.execute(credentials, options = {}) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rexchange/exchange_request.rb', line 12 def self.execute(credentials, = {}) http = Net::HTTP.new(credentials.uri.host, credentials.uri.port) http.set_debug_output(RExchange::DEBUG_STREAM) if RExchange::DEBUG_STREAM request_path = [:path] || credentials.uri.path req = self.new(request_path) req.basic_auth credentials.user, credentials.password req.content_type = 'text/xml' req.add_field 'host', credentials.uri.host if [:headers] [:headers].each_pair do |k, v| req.add_field k, v end end req.body = [:body] if REQUEST_HAS_BODY http.use_ssl = credentials.use_ssl? http.verify_mode = OpenSSL::SSL::VERIFY_NONE return http.request(req) if RESPONSE_HAS_BODY return true end |