videojuicer-vj-sdk 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/videojuicer/oauth/request_proxy.rb +28 -12
- data/lib/videojuicer/shared/exceptions.rb +6 -0
- data/vj-sdk.gemspec +2 -2
- metadata +2 -2
data/VERSION.yml
CHANGED
@@ -62,21 +62,25 @@ module Videojuicer
|
|
62
62
|
end
|
63
63
|
|
64
64
|
# Generate the HTTP Request and handle the response
|
65
|
-
url = "#{protocol}://#{host}:#{port}#{path}
|
66
|
-
request = request_class_for_method(method).new("#{path}?#{query_string}")
|
65
|
+
url = "#{protocol}://#{host}:#{port}#{path}"
|
66
|
+
request = request_class_for_method(method).new("#{path}?#{query_string}")
|
67
67
|
# Generate the multipart body and headers
|
68
|
-
if multipart_params.any?
|
68
|
+
if multipart_params.any?
|
69
69
|
post_body, content_type = Multipart::Post.new(multipart_params).to_multipart
|
70
70
|
request.content_length = post_body.length
|
71
71
|
request.content_type = content_type
|
72
72
|
request.body = post_body
|
73
|
+
else
|
74
|
+
# Send a content-length on POST and PUT to avoid an HTTP 411 response
|
75
|
+
case method
|
76
|
+
when :post, :put
|
77
|
+
request = request_class_for_method(method).new("#{path}")
|
78
|
+
request.content_type = "application/x-www-form-urlencoded"
|
79
|
+
request.body = query_string
|
80
|
+
request.content_length = query_string.length
|
81
|
+
end
|
73
82
|
end
|
74
83
|
|
75
|
-
# Send a content-length on POST and PUT to avoid an HTTP 411 response
|
76
|
-
case method
|
77
|
-
when :post, :put
|
78
|
-
request.content_length = 0
|
79
|
-
end
|
80
84
|
|
81
85
|
begin
|
82
86
|
#response = HTTPClient.send(method, url, multipart_params)
|
@@ -93,20 +97,32 @@ module Videojuicer
|
|
93
97
|
def handle_response(response, request)
|
94
98
|
c = response.code.to_i
|
95
99
|
case c
|
100
|
+
when 200..399
|
101
|
+
# Successful or redirected response
|
102
|
+
response
|
96
103
|
when 415
|
104
|
+
# Validation error
|
97
105
|
response
|
98
106
|
when 401
|
107
|
+
# Authentication problem
|
99
108
|
response_error Unauthenticated, response
|
100
109
|
when 403
|
110
|
+
# Attempted to perform a forbidden action
|
101
111
|
response_error Forbidden, response
|
112
|
+
when 404
|
113
|
+
# Resource URL not valid
|
114
|
+
response_error NoResource, response
|
102
115
|
when 406
|
116
|
+
# Excuse me WTF r u doin
|
103
117
|
response_error NotAcceptable, response
|
104
|
-
when
|
105
|
-
|
118
|
+
when 411
|
119
|
+
# App-side server error where request is not properly constructed.
|
120
|
+
response_error ContentLengthRequired, response
|
106
121
|
when 500..600
|
122
|
+
# Remote application failure
|
107
123
|
response_error RemoteApplicationError, response
|
108
124
|
else
|
109
|
-
response
|
125
|
+
response_error UnhandledHTTPStatus, response
|
110
126
|
end
|
111
127
|
end
|
112
128
|
|
@@ -117,7 +133,7 @@ module Videojuicer
|
|
117
133
|
e = e["error"]
|
118
134
|
raise exception_klass, "#{e["message"]} \n #{(e["backtrace"] || []).join("\n")}"
|
119
135
|
rescue JSON::ParserError
|
120
|
-
raise exception_klass
|
136
|
+
raise exception_klass, "#{exception_klass.to_s} : Response code was #{response.code}"
|
121
137
|
end
|
122
138
|
|
123
139
|
end
|
@@ -22,5 +22,11 @@ module Videojuicer
|
|
22
22
|
# Raised when status is 406
|
23
23
|
class NotAcceptable < ::StandardError; end
|
24
24
|
|
25
|
+
# Raised when status is 411
|
26
|
+
class ContentLengthRequired < ::StandardError; end
|
27
|
+
|
28
|
+
# Raised on an unclassified exception
|
29
|
+
class UnhandledHTTPStatus < ::StandardError; end
|
30
|
+
|
25
31
|
end
|
26
32
|
end
|
data/vj-sdk.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{vj-sdk}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.5"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["danski", "thejohnny", "knowtheory", "sixones"]
|
9
|
-
s.date = %q{2009-08-
|
9
|
+
s.date = %q{2009-08-07}
|
10
10
|
s.email = %q{dan@videojuicer.com}
|
11
11
|
s.extra_rdoc_files = [
|
12
12
|
"LICENSE",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: videojuicer-vj-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- danski
|
@@ -12,7 +12,7 @@ autorequire:
|
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
14
|
|
15
|
-
date: 2009-08-
|
15
|
+
date: 2009-08-07 00:00:00 -07:00
|
16
16
|
default_executable:
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|