simple-http-helper 0.0.1 → 0.0.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.
- checksums.yaml +4 -4
- data/lib/helpers/simple_http_helper.rb +11 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2c043c04da6398be133aceb004867ee5e033652
|
4
|
+
data.tar.gz: 6d08d4cadacd49007fb6aab3c06071d8d8bea936
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 667f44c6f771931780490295097ce899652fd887367fb4bd6b95830be283f69f9f8cfd4e86ab583146270b56e8b8c21528acf0af5c224208cf2eea77979dee3d
|
7
|
+
data.tar.gz: 10923d5da3a0037905a19d708ffa9190016742b3c0171bc651d157daa0d8f64a8a1a3753a319a006bbd1af42c2d0cb79f8ce3d5335020ca957ef2d64f65a1bf0
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'net/https'
|
3
3
|
require 'json'
|
4
|
+
require 'ostruct'
|
4
5
|
|
5
6
|
module HelperModule
|
6
7
|
|
7
|
-
# TODO: add SimpleHttpsHelper to support https requests
|
8
8
|
class SimpleRequestHelper
|
9
9
|
attr_reader :host, :port, :path
|
10
10
|
attr_accessor :_debug
|
@@ -13,6 +13,12 @@ module HelperModule
|
|
13
13
|
@host, @port, @path = host, port, path
|
14
14
|
end
|
15
15
|
|
16
|
+
def set_auth(username, password)
|
17
|
+
@auth = OpenStruct.new
|
18
|
+
@auth.username = username
|
19
|
+
@auth.password = password
|
20
|
+
end
|
21
|
+
|
16
22
|
def _request_prefix
|
17
23
|
raise NotImplementedError
|
18
24
|
end
|
@@ -42,7 +48,9 @@ module HelperModule
|
|
42
48
|
end
|
43
49
|
|
44
50
|
response = _create_request_sender(@host, @port).start do |http|
|
45
|
-
|
51
|
+
request = content.get_request
|
52
|
+
request.basic_auth(@auth.username, @auth.password) if @auth
|
53
|
+
http.request(request)
|
46
54
|
end
|
47
55
|
|
48
56
|
return SimpleHttpResult.new(response)
|
@@ -222,7 +230,7 @@ module HelperModule
|
|
222
230
|
end
|
223
231
|
|
224
232
|
def is_success?
|
225
|
-
@response.code.to_i == 200
|
233
|
+
@response.code.to_i == 200 || @response.code.to_i == 201
|
226
234
|
end
|
227
235
|
|
228
236
|
def error_message
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-http-helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yukai Jin
|
@@ -37,7 +37,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
37
|
version: '0'
|
38
38
|
requirements: []
|
39
39
|
rubyforge_project:
|
40
|
-
rubygems_version: 2.6.
|
40
|
+
rubygems_version: 2.6.14
|
41
41
|
signing_key:
|
42
42
|
specification_version: 4
|
43
43
|
summary: A simple http(s) request helper
|