gdata-19 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +8 -0
- data/Gemfile +4 -0
- data/LICENSE +202 -0
- data/README +97 -0
- data/Rakefile +2 -0
- data/gdata.gemspec +44 -0
- data/lib/gdata.rb +24 -0
- data/lib/gdata/auth.rb +22 -0
- data/lib/gdata/auth/authsub.rb +161 -0
- data/lib/gdata/auth/clientlogin.rb +102 -0
- data/lib/gdata/client.rb +84 -0
- data/lib/gdata/client/apps.rb +27 -0
- data/lib/gdata/client/base.rb +182 -0
- data/lib/gdata/client/blogger.rb +28 -0
- data/lib/gdata/client/booksearch.rb +28 -0
- data/lib/gdata/client/calendar.rb +58 -0
- data/lib/gdata/client/contacts.rb +28 -0
- data/lib/gdata/client/doclist.rb +28 -0
- data/lib/gdata/client/finance.rb +28 -0
- data/lib/gdata/client/gbase.rb +28 -0
- data/lib/gdata/client/gmail.rb +28 -0
- data/lib/gdata/client/health.rb +28 -0
- data/lib/gdata/client/notebook.rb +28 -0
- data/lib/gdata/client/photos.rb +29 -0
- data/lib/gdata/client/spreadsheets.rb +28 -0
- data/lib/gdata/client/webmaster_tools.rb +28 -0
- data/lib/gdata/client/youtube.rb +47 -0
- data/lib/gdata/http.rb +18 -0
- data/lib/gdata/http/default_service.rb +82 -0
- data/lib/gdata/http/mime_body.rb +95 -0
- data/lib/gdata/http/request.rb +74 -0
- data/lib/gdata/http/response.rb +44 -0
- data/lib/gdata/version.rb +3 -0
- data/test/tc_gdata_auth_authsub.rb +54 -0
- data/test/tc_gdata_auth_clientlogin.rb +60 -0
- data/test/tc_gdata_client_base.rb +38 -0
- data/test/tc_gdata_client_calendar.rb +41 -0
- data/test/tc_gdata_client_photos.rb +66 -0
- data/test/tc_gdata_client_youtube.rb +78 -0
- data/test/tc_gdata_http_mime_body.rb +47 -0
- data/test/tc_gdata_http_request.rb +37 -0
- data/test/test_config.yml.example +7 -0
- data/test/test_helper.rb +47 -0
- data/test/testimage.jpg +0 -0
- data/test/ts_gdata.rb +44 -0
- data/test/ts_gdata_auth.rb +26 -0
- data/test/ts_gdata_client.rb +30 -0
- data/test/ts_gdata_http.rb +25 -0
- metadata +129 -0
@@ -0,0 +1,58 @@
|
|
1
|
+
# Copyright (C) 2008 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module GData
|
16
|
+
module Client
|
17
|
+
|
18
|
+
# Client class to wrap working with the Calendar Data API.
|
19
|
+
class Calendar < Base
|
20
|
+
|
21
|
+
# Holds on to a session cookie
|
22
|
+
attr_accessor :session_cookie
|
23
|
+
|
24
|
+
def initialize(options = {})
|
25
|
+
options[:clientlogin_service] ||= 'cl'
|
26
|
+
options[:authsub_scope] ||= 'https://www.google.com/calendar/feeds/'
|
27
|
+
super(options)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Overrides auth_handler= so if the authentication changes,
|
31
|
+
# the session cookie is cleared.
|
32
|
+
def auth_handler=(handler)
|
33
|
+
@session_cookie = nil
|
34
|
+
return super(handler)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Overrides make_request to handle 302 redirects with a session cookie.
|
38
|
+
def make_request(method, url, body = '', retries = 4)
|
39
|
+
response = super(method, url, body)
|
40
|
+
if response.status_code == 302 and retries > 0
|
41
|
+
@session_cookie = response.headers['set-cookie']
|
42
|
+
return self.make_request(method, url, body,
|
43
|
+
retries - 1)
|
44
|
+
else
|
45
|
+
return response
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Custom prepare_headers to include the session cookie if it exists
|
50
|
+
def prepare_headers
|
51
|
+
if @session_cookie
|
52
|
+
@headers['cookie'] = @session_cookie
|
53
|
+
end
|
54
|
+
super
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Copyright (C) 2008 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module GData
|
16
|
+
module Client
|
17
|
+
|
18
|
+
# Client class to wrap working with the Contacts API.
|
19
|
+
class Contacts < Base
|
20
|
+
|
21
|
+
def initialize(options = {})
|
22
|
+
options[:clientlogin_service] ||= 'cp'
|
23
|
+
options[:authsub_scope] ||= 'https://www.google.com/m8/feeds/'
|
24
|
+
super(options)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Copyright (C) 2008 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module GData
|
16
|
+
module Client
|
17
|
+
|
18
|
+
# Client class to wrap working with the Documents List Data API.
|
19
|
+
class DocList < Base
|
20
|
+
|
21
|
+
def initialize(options = {})
|
22
|
+
options[:clientlogin_service] ||= 'writely'
|
23
|
+
options[:authsub_scope] ||= 'https://docs.google.com/feeds/'
|
24
|
+
super(options)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Copyright (C) 2008 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module GData
|
16
|
+
module Client
|
17
|
+
|
18
|
+
# Client class to wrap working with the Finance API.
|
19
|
+
class Finance < Base
|
20
|
+
|
21
|
+
def initialize(options = {})
|
22
|
+
options[:clientlogin_service] ||= 'finance'
|
23
|
+
options[:authsub_scope] ||= 'http://finance.google.com/finance/feeds/'
|
24
|
+
super(options)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Copyright (C) 2008 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module GData
|
16
|
+
module Client
|
17
|
+
|
18
|
+
# Client class to wrap working with the Google Base API.
|
19
|
+
class GBase < Base
|
20
|
+
|
21
|
+
def initialize(options = {})
|
22
|
+
options[:clientlogin_service] ||= 'gbase'
|
23
|
+
options[:authsub_scope] ||= 'https://www.google.com/base/feeds/'
|
24
|
+
super(options)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Copyright (C) 2008 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module GData
|
16
|
+
module Client
|
17
|
+
|
18
|
+
# Client class to wrap working with the GMail Atom Feed.
|
19
|
+
class GMail < Base
|
20
|
+
|
21
|
+
def initialize(options = {})
|
22
|
+
options[:clientlogin_service] ||= 'mail'
|
23
|
+
options[:authsub_scope] ||= 'https://mail.google.com/mail/feed/atom/'
|
24
|
+
super(options)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Copyright (C) 2008 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module GData
|
16
|
+
module Client
|
17
|
+
|
18
|
+
# Client class to wrap working with the Health API.
|
19
|
+
class Health < Base
|
20
|
+
|
21
|
+
def initialize(options = {})
|
22
|
+
options[:clientlogin_service] ||= 'health'
|
23
|
+
options[:authsub_scope] ||= 'https://www.google.com/health/feeds/'
|
24
|
+
super(options)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Copyright (C) 2008 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module GData
|
16
|
+
module Client
|
17
|
+
|
18
|
+
# Client class to wrap working with the Notebook Data API.
|
19
|
+
class Notebook < Base
|
20
|
+
|
21
|
+
def initialize(options = {})
|
22
|
+
options[:clientlogin_service] ||= 'notebook'
|
23
|
+
options[:authsub_scope] ||= 'https://www.google.com/notebook/feeds/'
|
24
|
+
super(options)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Copyright (C) 2008 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module GData
|
16
|
+
module Client
|
17
|
+
|
18
|
+
# Client class to wrap working with the Picasa Web Albums API.
|
19
|
+
class Photos < Base
|
20
|
+
|
21
|
+
def initialize(options = {})
|
22
|
+
options[:clientlogin_service] ||= 'lh2'
|
23
|
+
options[:authsub_scope] ||= 'https://picasaweb.google.com/data/'
|
24
|
+
options[:version] ||= '1'
|
25
|
+
super(options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Copyright (C) 2008 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module GData
|
16
|
+
module Client
|
17
|
+
|
18
|
+
# Client class to wrap working with the Spreadsheets API.
|
19
|
+
class Spreadsheets < Base
|
20
|
+
|
21
|
+
def initialize(options = {})
|
22
|
+
options[:clientlogin_service] ||= 'wise'
|
23
|
+
options[:authsub_scope] ||= 'https://spreadsheets.google.com/feeds/'
|
24
|
+
super(options)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Copyright (C) 2008 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module GData
|
16
|
+
module Client
|
17
|
+
|
18
|
+
# Client class to wrap working with the Webmaster Tools API.
|
19
|
+
class WebmasterTools < Base
|
20
|
+
|
21
|
+
def initialize(options = {})
|
22
|
+
options[:clientlogin_service] ||= 'sitemaps'
|
23
|
+
options[:authsub_scope] ||= 'https://www.google.com/webmasters/tools/feeds/'
|
24
|
+
super(options)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# Copyright (C) 2008 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
module GData
|
16
|
+
module Client
|
17
|
+
|
18
|
+
# Client class to wrap working with the YouTube API. Sets some
|
19
|
+
# YouTube-specific options.
|
20
|
+
class YouTube < Base
|
21
|
+
|
22
|
+
# The YouTube developer key being used.
|
23
|
+
attr_accessor :developer_key
|
24
|
+
# The YouTube ClientID being used.
|
25
|
+
attr_accessor :client_id
|
26
|
+
|
27
|
+
def initialize(options = {})
|
28
|
+
options[:clientlogin_service] ||= 'youtube'
|
29
|
+
options[:clientlogin_url] ||= 'https://www.google.com/youtube/accounts/ClientLogin'
|
30
|
+
options[:authsub_scope] ||= 'http://gdata.youtube.com'
|
31
|
+
options[:version] ||= '2'
|
32
|
+
super(options)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Custom prepare_headers to include the developer key and clientID
|
36
|
+
def prepare_headers
|
37
|
+
if @client_id
|
38
|
+
@headers['X-GData-Client'] = @client_id
|
39
|
+
end
|
40
|
+
if @developer_key
|
41
|
+
@headers['X-GData-Key'] = "key=#{@developer_key}"
|
42
|
+
end
|
43
|
+
super
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/gdata/http.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# Copyright (C) 2008 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'gdata/http/default_service'
|
16
|
+
require 'gdata/http/mime_body'
|
17
|
+
require 'gdata/http/request'
|
18
|
+
require 'gdata/http/response'
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# Copyright (C) 2008 Google Inc.
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
require 'net/http'
|
16
|
+
require 'net/https'
|
17
|
+
require 'uri'
|
18
|
+
|
19
|
+
module GData
|
20
|
+
module HTTP
|
21
|
+
|
22
|
+
# This is the default implementation of the HTTP layer that uses
|
23
|
+
# Net::HTTP. You could roll your own if you have different requirements
|
24
|
+
# or cannot use Net::HTTP for some reason.
|
25
|
+
class DefaultService
|
26
|
+
|
27
|
+
# Take a GData::HTTP::Request, execute the request, and return a
|
28
|
+
# GData::HTTP::Response object.
|
29
|
+
def make_request(request)
|
30
|
+
url = URI.parse(request.url)
|
31
|
+
http = Net::HTTP.new(url.host, url.port)
|
32
|
+
http.use_ssl = (url.scheme == 'https')
|
33
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
34
|
+
|
35
|
+
case request.method
|
36
|
+
when :get
|
37
|
+
req = Net::HTTP::Get.new(url.request_uri)
|
38
|
+
when :put
|
39
|
+
req = Net::HTTP::Put.new(url.request_uri)
|
40
|
+
when :post
|
41
|
+
req = Net::HTTP::Post.new(url.request_uri)
|
42
|
+
when :delete
|
43
|
+
req = Net::HTTP::Delete.new(url.request_uri)
|
44
|
+
else
|
45
|
+
raise ArgumentError, "Unsupported HTTP method specified."
|
46
|
+
end
|
47
|
+
|
48
|
+
case request.body
|
49
|
+
when String
|
50
|
+
req.body = request.body
|
51
|
+
when Hash
|
52
|
+
req.set_form_data(request.body)
|
53
|
+
when File
|
54
|
+
req.body_stream = request.body
|
55
|
+
request.chunked = true
|
56
|
+
when GData::HTTP::MimeBody
|
57
|
+
req.body_stream = request.body
|
58
|
+
request.chunked = true
|
59
|
+
else
|
60
|
+
req.body = request.body.to_s
|
61
|
+
end
|
62
|
+
|
63
|
+
request.headers.each do |key, value|
|
64
|
+
req[key] = value
|
65
|
+
end
|
66
|
+
|
67
|
+
request.calculate_length!
|
68
|
+
|
69
|
+
res = http.request(req)
|
70
|
+
|
71
|
+
response = Response.new
|
72
|
+
response.body = res.body
|
73
|
+
response.headers = Hash.new
|
74
|
+
res.each do |key, value|
|
75
|
+
response.headers[key] = value
|
76
|
+
end
|
77
|
+
response.status_code = res.code.to_i
|
78
|
+
return response
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|