lib/s33r/client.rb in s33r-0.5.3 vs lib/s33r/client.rb in s33r-0.5.4

- old
+ new

@@ -8,10 +8,13 @@ #-- These are used for creating URLs. # Use SSL for requests. attr_accessor :use_ssl + + # Use subdomains (set on host header) + attr_accessor :subdomain # Default expiry for authenticated URLs. attr_accessor :expires # Default canned ACL string to apply to all put requests. @@ -22,10 +25,11 @@ # Get default options passed to every call to do_request. def request_defaults defaults = {} defaults[:use_ssl] = @use_ssl + defaults[:subdomain] = @subdomain defaults[:expires] = @expires defaults[:access] = @access defaults[:secret] = @secret defaults[:canned_acl] = @canned_acl defaults @@ -61,10 +65,11 @@ # disable this behaviour (see url for details). # * <tt>:expires => <datetime specifier></tt>: set the default value to be passed as the :expires # option when generating authenticated URLs. Should be parseable by S33r.parse_expiry. # * <tt>:canned_acl => 'public-read'</tt>: set a default canned acl to apply to all put # requests. + # * <tt>:subdomain => false</tt>: set to true to use subdomains in URLs # # These options change the behaviour of the HTTP client which actually sends the request: # * <tt>:chunk_size => Integer</tt>: use a non-standard chunk size; # default is to use S33r::DEFAULT_CHUNK_SIZE. # * <tt>:persistent => true</tt>: use persistent HTTP connections @@ -72,10 +77,12 @@ # * <tt>:dump_requests => true</tt>: to dump all request headers before the request is sent. def set_options(options={}) # General client options. @access = options[:access] @secret = options[:secret] + @subdomain = false + @subdomain = true if (true == options[:subdomain]) @use_ssl = true @use_ssl = false if (false == options[:use_ssl]) @expires = options[:expires] || 'never' @canned_acl = options[:canned_acl] || nil @@ -188,11 +195,11 @@ key_sym = key.to_sym querystring[key] = options[key_sym] if options[key_sym] end options[:querystring] = querystring - + resp = do_get(options) if resp.ok? @listing = BucketListing.new(resp.body) else @@ -373,11 +380,11 @@ # If :bucket and :for_bucket are provided, :bucket takes preference. # * <tt>:prefix => 'some-prefix-'</tt>: specify a prefix for log files; # otherwise 'log-<bucket name>-' is used def logs_to(target_bucket, options={}) target_bucket_name = target_bucket.is_a?(Bucket) ? target_bucket.name : target_bucket - log_prefix = options[:prefix] || "log-#{bucket_name}-" + log_prefix = options[:prefix] || "log-#{target_bucket_name}-" options[:bucket] ||= options[:for_bucket] target_bucket_acl = get_acl(:bucket => target_bucket_name) unless target_bucket_acl.log_targetable? raise BucketNotLogTargetable, "The bucket #{target_bucket_name} cannot be specified as a log target" @@ -395,6 +402,6 @@ def logs_off(options={}) options[:logging] = true put(LoggingResource.new, options) end end -end \ No newline at end of file +end