basic_auth_http 0.0.1
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 +7 -0
- data/lib/basic_auth_http.rb +37 -0
- metadata +42 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 5a5b4f6b646e81fe5d37e2d118c21812fa60dac1c89965013c734cea779be5f6
|
|
4
|
+
data.tar.gz: f531c621e89c7c49f293696f59e4f365f402034e7bff038339d1147c5551d5bb
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: b7516ff3bb5470bd36b71eb4cc041093d54aee156449c006e75119fd7d18c08abc89e3fde6cf88fa908eccc878ce24966c799be8b7b8cf1270fa192ad021441c
|
|
7
|
+
data.tar.gz: b7e26d1508f7cd030ea6c0cd12d041a88654f53d298ea4cf460b52904069b6816c85e7308af282c0c7c22b41c8e5ed95ff6500391214dc2e0a514b90a20517f1
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
require 'uri'
|
|
2
|
+
require 'net/http'
|
|
3
|
+
|
|
4
|
+
class BasicAuthHTTP
|
|
5
|
+
@username=nil
|
|
6
|
+
@password=nil
|
|
7
|
+
|
|
8
|
+
def initialize user=nil, password=nil
|
|
9
|
+
@username = user # Rails.application.credentials.github_api_user
|
|
10
|
+
@password = password # Rails.application.credentials.github_api_token
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def get_user
|
|
14
|
+
return @username
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def get_request url=nil, extra_fields=nil, auth=true
|
|
18
|
+
if not url.nil?
|
|
19
|
+
@uri = URI.parse(url)
|
|
20
|
+
http = Net::HTTP.new(@uri.host, @uri.port)
|
|
21
|
+
req = Net::HTTP::Get.new(@uri.request_uri)
|
|
22
|
+
http.use_ssl = (@uri.scheme == "https")
|
|
23
|
+
if not extra_fields.nil?
|
|
24
|
+
extra_fields.each do |header|
|
|
25
|
+
req.add_field(header['field'], header['field_value'])
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
if auth
|
|
29
|
+
req.basic_auth(@username, @password)
|
|
30
|
+
end
|
|
31
|
+
res = http.request(req)
|
|
32
|
+
return res
|
|
33
|
+
else
|
|
34
|
+
return nil
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end # End Module
|
metadata
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: basic_auth_http
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- stefdworschak
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-03-20 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Send HTTP requests using Basic Authentication
|
|
14
|
+
email: stef.dworschak@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- lib/basic_auth_http.rb
|
|
20
|
+
homepage: http://rubygems.org/gems/basic_auth_http
|
|
21
|
+
licenses: []
|
|
22
|
+
metadata: {}
|
|
23
|
+
post_install_message:
|
|
24
|
+
rdoc_options: []
|
|
25
|
+
require_paths:
|
|
26
|
+
- lib
|
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
28
|
+
requirements:
|
|
29
|
+
- - ">="
|
|
30
|
+
- !ruby/object:Gem::Version
|
|
31
|
+
version: '0'
|
|
32
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
33
|
+
requirements:
|
|
34
|
+
- - ">="
|
|
35
|
+
- !ruby/object:Gem::Version
|
|
36
|
+
version: '0'
|
|
37
|
+
requirements: []
|
|
38
|
+
rubygems_version: 3.0.3
|
|
39
|
+
signing_key:
|
|
40
|
+
specification_version: 4
|
|
41
|
+
summary: Send HTTP requests using Basic Authentication
|
|
42
|
+
test_files: []
|