protocol-http 0.8.1 → 0.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6569a6a5cc9ab8434a97cd690c5a430eb752ebf4ea1a16dda17713ee22da53e6
4
- data.tar.gz: 04e72bc086e462de72f7bb69d2dcaf7a847e7e3be2026b9e4a090636027747bd
3
+ metadata.gz: 30678c8f31c20a2daa56b58fe3b599af480c76560cae3e9d0d6cebd6fc854767
4
+ data.tar.gz: 89dc121efa998bda14f7cc4ab60392fdcccad0cf3f9dae0cf6b497c70f4949bc
5
5
  SHA512:
6
- metadata.gz: 34dc5af42cfebdd457752d15422ca9a47c0ece1e16bd3992a4838a8a985fa87b3de9bbce9089ee878dd6246b3adc0d98ea5fb54daf56d4437171f3e5fc1d6e0f
7
- data.tar.gz: e524a16fd89bd9b398b3c107a5f5cf98748c2fc950544726a6632483a024bf8f15767c605092c2b0aedd143595a87520eabe7a5b31a6d2c0fa3d9758ac345c7b
6
+ metadata.gz: c9821a48ac5c2c26e88e465a427a81956649ac12d4b493af762a788222df569bba9b8b15e696c3888abd391e81fa8d32d62e81d93f90b03d7754a8db06768c5a
7
+ data.tar.gz: b86dde999df7c4f23827d381c2500798255833d9cfaf2e9118679c34c51a72cf4cfcd70ef67263e362585a147010e298433da85065ed6dae736d91ae7b2139af
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+ #
3
+ # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+
23
+ require 'base64'
24
+
25
+ module Protocol
26
+ module HTTP
27
+ module Header
28
+ # Used for basic authorization.
29
+ # @example headers.add(*Authorization.new("samuel", "password"))
30
+ class Authorization
31
+ KEY = "Authorization"
32
+
33
+ def initialize(username, password)
34
+ @username = username
35
+ @password = password
36
+ end
37
+
38
+ def to_ary
39
+ return KEY, self.to_str
40
+ end
41
+
42
+ def encoded
43
+ "#{@username}:#{@password}"
44
+ end
45
+
46
+ def to_str
47
+ 'Basic %s' % Base64.strict_encode64(self.encoded)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -36,6 +36,13 @@ module Protocol
36
36
  TRACE = 'TRACE'
37
37
  CONNECT = 'CONNECT'
38
38
 
39
+ def self.valid?(name)
40
+ const_defined?(name)
41
+ rescue NameError
42
+ # Ruby will raise an exception if te name is not valid for a constant.
43
+ return false
44
+ end
45
+
39
46
  def self.each
40
47
  constants.each do |name|
41
48
  yield name, const_get(name)
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Protocol
22
22
  module HTTP
23
- VERSION = "0.8.1"
23
+ VERSION = "0.9.1"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-19 00:00:00.000000000 Z
11
+ date: 2019-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: covered
@@ -94,6 +94,7 @@ files:
94
94
  - lib/protocol/http/body/wrapper.rb
95
95
  - lib/protocol/http/content_encoding.rb
96
96
  - lib/protocol/http/error.rb
97
+ - lib/protocol/http/header/authorization.rb
97
98
  - lib/protocol/http/headers.rb
98
99
  - lib/protocol/http/methods.rb
99
100
  - lib/protocol/http/middleware.rb