Skip to content

Commit 3ca8e75

Browse files
committed
fix indenting in files
1 parent 766aded commit 3ca8e75

File tree

6 files changed

+1164
-1163
lines changed

6 files changed

+1164
-1163
lines changed

S3_s3sync_mod.rb

+107-107
Original file line numberDiff line numberDiff line change
@@ -25,119 +25,119 @@
2525
# to the underlying lib this stuff will need updating.
2626

2727
module S3
28-
class AWSAuthConnection
28+
class AWSAuthConnection
2929

30-
def make_http(bucket='', host='', proxy_host=nil, proxy_port=nil, proxy_user=nil, proxy_pass=nil)
30+
def make_http(bucket='', host='', proxy_host=nil, proxy_port=nil, proxy_user=nil, proxy_pass=nil)
3131

32-
# build the domain based on the calling format
33-
server = ''
34-
if host != ''
35-
server = host
36-
elsif bucket.empty?
37-
# for a bucketless request (i.e. list all buckets)
38-
# revert to regular domain case since this operation
39-
# does not make sense for vanity domains
40-
server = @server
41-
elsif @calling_format == CallingFormat::SUBDOMAIN
42-
server = "#{bucket}.#{@server}"
43-
elsif @calling_format == CallingFormat::VANITY
44-
server = bucket
45-
else
46-
server = @server
47-
end
48-
# automatically does the right thing when no proxy
49-
http = Net::HTTP::Proxy(proxy_host, proxy_port, proxy_user, proxy_pass).new(server, @port)
50-
#http = Net::HTTP.new(server, @port)
51-
http.use_ssl = @is_secure
52-
http.verify_mode=@verify_mode
53-
http.ca_file=@ca_file
54-
http.ca_path=@ca_path
55-
http.start
56-
return http
32+
# build the domain based on the calling format
33+
server = ''
34+
if host != ''
35+
server = host
36+
elsif bucket.empty?
37+
# for a bucketless request (i.e. list all buckets)
38+
# revert to regular domain case since this operation
39+
# does not make sense for vanity domains
40+
server = @server
41+
elsif @calling_format == CallingFormat::SUBDOMAIN
42+
server = "#{bucket}.#{@server}"
43+
elsif @calling_format == CallingFormat::VANITY
44+
server = bucket
45+
else
46+
server = @server
5747
end
58-
59-
# add support for streaming the response body to an IO stream
60-
alias __make_request__ make_request
61-
def make_request(method, bucket='', key='', path_args={}, headers={}, data='', metadata={}, streamOut=nil)
62-
# build the path based on the calling format
63-
path = ''
64-
if (not bucket.empty?) and (@calling_format == CallingFormat::REGULAR)
65-
path << "/#{bucket}"
66-
end
67-
# add the slash after the bucket regardless
68-
# the key will be appended if it is non-empty
69-
path << "/#{key}"
70-
71-
# build the path_argument string
72-
# add the ? in all cases since
73-
# signature and credentials follow path args
74-
path << '?'
75-
path << S3.path_args_hash_to_string(path_args)
76-
77-
req = method_to_request_class(method).new("#{path}")
78-
79-
set_headers(req, headers)
80-
set_headers(req, metadata, METADATA_PREFIX)
81-
set_headers(req, {'Connection' => 'keep-alive', 'Keep-Alive' => '300'})
82-
83-
set_aws_auth_header(req, @aws_access_key_id, @aws_secret_access_key, bucket, key, path_args)
84-
85-
http = $S3syncHttp
86-
87-
if req.request_body_permitted?
88-
return http.request(req, data, streamOut)
89-
else
90-
return http.request(req, nil, streamOut)
91-
end
48+
# automatically does the right thing when no proxy
49+
http = Net::HTTP::Proxy(proxy_host, proxy_port, proxy_user, proxy_pass).new(server, @port)
50+
#http = Net::HTTP.new(server, @port)
51+
http.use_ssl = @is_secure
52+
http.verify_mode=@verify_mode
53+
http.ca_file=@ca_file
54+
http.ca_path=@ca_path
55+
http.start
56+
return http
57+
end
58+
59+
# add support for streaming the response body to an IO stream
60+
alias __make_request__ make_request
61+
def make_request(method, bucket='', key='', path_args={}, headers={}, data='', metadata={}, streamOut=nil)
62+
# build the path based on the calling format
63+
path = ''
64+
if (not bucket.empty?) and (@calling_format == CallingFormat::REGULAR)
65+
path << "/#{bucket}"
9266
end
93-
94-
# a "get" operation that sends the body to an IO stream
95-
def get_stream(bucket, key, headers={}, streamOut=nil)
96-
return GetResponse.new(make_request('GET', bucket, CGI::escape(key), {}, headers, '', {}, streamOut))
97-
end
98-
99-
# a "get" operation that sends the body to an IO stream
100-
def get_query_stream(bucket, key, path_args={}, headers={}, streamOut=nil)
101-
return GetResponse.new(make_request('GET', bucket, CGI::escape(key), path_args, headers, '', {}, streamOut))
102-
end
67+
# add the slash after the bucket regardless
68+
# the key will be appended if it is non-empty
69+
path << "/#{key}"
70+
71+
# build the path_argument string
72+
# add the ? in all cases since
73+
# signature and credentials follow path args
74+
path << '?'
75+
path << S3.path_args_hash_to_string(path_args)
76+
77+
req = method_to_request_class(method).new("#{path}")
78+
79+
set_headers(req, headers)
80+
set_headers(req, metadata, METADATA_PREFIX)
81+
set_headers(req, {'Connection' => 'keep-alive', 'Keep-Alive' => '300'})
10382

104-
def head(bucket, key=nil, headers={})
105-
return GetResponse.new(make_request('HEAD', bucket, CGI::escape(key), {}, headers, '', {}))
106-
end
107-
undef create_bucket
108-
def create_bucket(bucket, object)
109-
object = S3Object.new(object) if not object.instance_of? S3Object
110-
return Response.new(
111-
make_request('PUT', bucket, '', {}, {}, object.data, object.metadata)
112-
)
83+
set_aws_auth_header(req, @aws_access_key_id, @aws_secret_access_key, bucket, key, path_args)
84+
85+
http = $S3syncHttp
86+
87+
if req.request_body_permitted?
88+
return http.request(req, data, streamOut)
89+
else
90+
return http.request(req, nil, streamOut)
11391
end
114-
# no, because internally the library does not support the header,wait,body paradigm, so this is useless
115-
#alias __put__ put
116-
#def put(bucket, key, object, headers={})
117-
# headers['Expect'] = "100-continue"
118-
# __put__(bucket, key, object, headers)
119-
#end
120-
92+
end
93+
94+
# a "get" operation that sends the body to an IO stream
95+
def get_stream(bucket, key, headers={}, streamOut=nil)
96+
return GetResponse.new(make_request('GET', bucket, CGI::escape(key), {}, headers, '', {}, streamOut))
97+
end
98+
99+
# a "get" operation that sends the body to an IO stream
100+
def get_query_stream(bucket, key, path_args={}, headers={}, streamOut=nil)
101+
return GetResponse.new(make_request('GET', bucket, CGI::escape(key), path_args, headers, '', {}, streamOut))
102+
end
103+
104+
def head(bucket, key=nil, headers={})
105+
return GetResponse.new(make_request('HEAD', bucket, CGI::escape(key), {}, headers, '', {}))
106+
end
107+
undef create_bucket
108+
def create_bucket(bucket, object)
109+
object = S3Object.new(object) if not object.instance_of? S3Object
110+
return Response.new(
111+
make_request('PUT', bucket, '', {}, {}, object.data, object.metadata)
112+
)
113+
end
114+
# no, because internally the library does not support the header,wait,body paradigm, so this is useless
115+
#alias __put__ put
116+
#def put(bucket, key, object, headers={})
117+
# headers['Expect'] = "100-continue"
118+
# __put__(bucket, key, object, headers)
119+
#end
120+
121121

122-
# allow ssl validation
123-
attr_accessor :verify_mode
124-
attr_accessor :ca_path
125-
attr_accessor :ca_file
126-
127-
end
128-
module CallingFormat
129-
def CallingFormat.string_to_format(s)
130-
case s
131-
when 'REGULAR'
132-
return CallingFormat::REGULAR
133-
when 'SUBDOMAIN'
134-
return CallingFormat::SUBDOMAIN
135-
when 'VANITY'
136-
return CallingFormat::VANITY
137-
else
138-
raise "Unsupported calling format #{s}"
139-
end
122+
# allow ssl validation
123+
attr_accessor :verify_mode
124+
attr_accessor :ca_path
125+
attr_accessor :ca_file
126+
127+
end
128+
module CallingFormat
129+
def CallingFormat.string_to_format(s)
130+
case s
131+
when 'REGULAR'
132+
return CallingFormat::REGULAR
133+
when 'SUBDOMAIN'
134+
return CallingFormat::SUBDOMAIN
135+
when 'VANITY'
136+
return CallingFormat::VANITY
137+
else
138+
raise "Unsupported calling format #{s}"
140139
end
141-
end
142-
140+
end
141+
end
142+
143143
end

S3encoder.rb

+28-28
Original file line numberDiff line numberDiff line change
@@ -18,33 +18,33 @@
1818

1919
# thanks to http://www.redhillconsulting.com.au/blogs/simon/archives/000326.html
2020
module S3ExtendCGI
21-
def self.included(base)
22-
base.extend(ClassMethods)
23-
base.class_eval do
24-
class << self
25-
alias_method :S3Extend_escape_orig, :escape unless method_defined?(:S3Extend_escape_orig)
26-
alias_method :escape, :S3Extend_escape
27-
end
28-
end
29-
end
30-
module ClassMethods
31-
@@exemptSlashesInEscape = false
32-
attr_writer :exemptSlashesInEscape
33-
@@usePercent20InEscape = false
34-
attr_writer :usePercent20InEscape
35-
@@nativeCharacterEncoding = "ISO-8859-1"
36-
attr_writer :nativeCharacterEncoding
37-
@@useUTF8InEscape = false
38-
attr_writer :useUTF8InEscape
39-
40-
def S3Extend_escape(string)
41-
result = string
42-
result = Iconv.iconv("UTF-8", @nativeCharacterEncoding, string).join if @useUTF8InEscape
43-
result = S3Extend_escape_orig(result)
44-
result.gsub!(/%2f/i, "/") if @exemptSlashesInEscape
45-
result.gsub!("+", "%20") if @usePercent20InEscape
46-
result
47-
end
48-
end
21+
def self.included(base)
22+
base.extend(ClassMethods)
23+
base.class_eval do
24+
class << self
25+
alias_method :S3Extend_escape_orig, :escape unless method_defined?(:S3Extend_escape_orig)
26+
alias_method :escape, :S3Extend_escape
27+
end
28+
end
29+
end
30+
module ClassMethods
31+
@@exemptSlashesInEscape = false
32+
attr_writer :exemptSlashesInEscape
33+
@@usePercent20InEscape = false
34+
attr_writer :usePercent20InEscape
35+
@@nativeCharacterEncoding = "ISO-8859-1"
36+
attr_writer :nativeCharacterEncoding
37+
@@useUTF8InEscape = false
38+
attr_writer :useUTF8InEscape
39+
40+
def S3Extend_escape(string)
41+
result = string
42+
result = Iconv.iconv("UTF-8", @nativeCharacterEncoding, string).join if @useUTF8InEscape
43+
result = S3Extend_escape_orig(result)
44+
result.gsub!(/%2f/i, "/") if @exemptSlashesInEscape
45+
result.gsub!("+", "%20") if @usePercent20InEscape
46+
result
47+
end
48+
end
4949
end
5050
CGI.send(:include, S3ExtendCGI)

0 commit comments

Comments
 (0)