htty 1.5.5 → 1.5.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cfa89b632f037b19e446cf0d93caacfda4c4ee06
4
- data.tar.gz: 91f979a8b2919e9a03875a9d0320bed63b6c6872
3
+ metadata.gz: bef059d23fabb8977b1c724590cd62bc1a164a4a
4
+ data.tar.gz: 08bb998dbc5f51f8f102ec0b0917b6efd114e046
5
5
  SHA512:
6
- metadata.gz: 8eefb6673967dc17ca3748a6a2ae5862b81f13c89140c6e25c91714acb11d8cba2ab64931b2e36d7616363016bda7f24aaf76531dbbdbc7ad6e7c8893afc59d8
7
- data.tar.gz: 6c7938e36f4f238b6e9e392b1e4977c88712d3d945a0f4c87ec774234e9a77476442dd7fe9f1b00e5aea43790a7a9a2dec9755de181569731389dfb1ab5e2fd1
6
+ metadata.gz: 1245d3eac192a6abdcfcefe47b881ce9dfa2ad8553e1b4b536c23e2da540ae1d75224d9a33e1a8a28b23ea93d7b5538d6011942921953e78ba59db1681b0cdb0
7
+ data.tar.gz: c0e6f2da76971ed227013b3a8f3c81b2b2f999cbbc2b38d35c6e28c1c3507faf65705cee98758179fbb9d03d8b1fa48ef804356414691995bcbffe46393ddc9c
@@ -1,6 +1,13 @@
1
1
  Version history for the _htty_ project
2
2
  ======================================
3
3
 
4
+ <a name="v1.5.7"></a>v1.5.7, Thu 12/10/2015
5
+ -------------------------------------------
6
+
7
+ * Added response benchmarking [[presskey](http://github.com/presskey "presskey at GitHub")]
8
+ * Fixed bugs in server certificate verification under Ruby v2
9
+ * Fixed a bug in validation of arguments to the `path-set` command
10
+
4
11
  <a name="v1.5.5"></a>v1.5.5, Tue 10/20/2015
5
12
  -------------------------------------------
6
13
 
@@ -1,3 +1,5 @@
1
+ require 'net/http'
2
+
1
3
  # Contains the implementation of _htty_.
2
4
  module HTTY
3
5
 
@@ -23,7 +25,7 @@ end
23
25
 
24
26
  module Net
25
27
 
26
- class HTTP
28
+ class HTTP < Protocol
27
29
 
28
30
  autoload :Patch, 'htty/http_patch'
29
31
 
@@ -25,12 +25,7 @@ class HTTY::CLI::Commands::Help < HTTY::CLI::Command
25
25
  def perform
26
26
  return display_help if arguments.empty?
27
27
 
28
- unless arguments.length == 1
29
- raise ArgumentError,
30
- "wrong number of arguments (#{arguments.length} for 1)"
31
- end
32
-
33
- display_help_for arguments.first
28
+ display_help_for(*arguments)
34
29
  end
35
30
 
36
31
  private
@@ -37,18 +37,18 @@ class HTTY::CLI::Commands::PathSet < HTTY::CLI::Command
37
37
  end
38
38
 
39
39
  def self.sanitize_arguments(arguments)
40
- path = arguments[0]
41
- path_components = path.split('/')
42
- escaped_components = escape_or_warn_of_escape_sequences(path_components)
43
- escaped_path = escaped_components.join('/')
44
- [escaped_path]
40
+ arguments.collect do |argument|
41
+ path_components = argument.split('/')
42
+ escaped_components = escape_or_warn_of_escape_sequences(path_components)
43
+ escaped_components.join '/'
44
+ end
45
45
  end
46
46
 
47
47
  # Performs the _path-set_ command.
48
48
  def perform
49
49
  add_request_if_new do |request|
50
50
  self.class.notify_if_cookies_cleared request do
51
- request.path_set(arguments[0])
51
+ request.path_set(*arguments)
52
52
  end
53
53
  end
54
54
  end
@@ -51,6 +51,7 @@ class HTTY::CLI::Commands::QueryAdd < HTTY::CLI::Command
51
51
  if arguments.empty?
52
52
  raise ArgumentError, 'wrong number of arguments (0 for N)'
53
53
  end
54
+
54
55
  add_request_if_new do |request|
55
56
  self.class.notify_if_cookies_cleared request do
56
57
  escaped_arguments = escape_or_warn_of_escape_sequences(arguments)
@@ -51,6 +51,7 @@ class HTTY::CLI::Commands::QuerySet < HTTY::CLI::Command
51
51
  if arguments.empty?
52
52
  raise ArgumentError, 'wrong number of arguments (0 for N)'
53
53
  end
54
+
54
55
  add_request_if_new do |request|
55
56
  self.class.notify_if_cookies_cleared request do
56
57
  escaped_arguments = escape_or_warn_of_escape_sequences(arguments)
@@ -153,11 +153,12 @@ module HTTY::CLI::Display
153
153
  end
154
154
  print ' '
155
155
  cookies_asterisk = response.cookies.empty? ? '' : strong('*')
156
- body_length = response.body.to_s.length
157
- body_size = body_length.zero? ? 'empty' : "#{body_length}-character"
156
+ body_length = response.body.to_s.length
157
+ body_size = body_length.zero? ? 'empty' : "#{body_length}-character"
158
+ response_time_ms = (response.time * 1000).round(2)
158
159
  puts([description,
159
160
  pluralize('header', response.headers.length) + cookies_asterisk,
160
- "#{body_size} body"].join(' -- '))
161
+ "#{body_size} body", "#{response_time_ms} ms"].join(' -- '))
161
162
  end
162
163
 
163
164
  def strong(string)
@@ -1,4 +1,5 @@
1
1
  require 'htty'
2
+ require 'openssl'
2
3
 
3
4
  # Encapsulates behavior common to all HTTP-method-oriented HTTY::CLI::Command
4
5
  # subclasses.
@@ -1,6 +1,8 @@
1
+ require 'benchmark'
1
2
  require 'htty'
2
3
  require 'net/http'
3
4
  require 'net/https'
5
+ require 'openssl'
4
6
  require 'uri'
5
7
 
6
8
  # Provides support for making HTTP(S) requests.
@@ -89,7 +91,11 @@ private
89
91
  end
90
92
 
91
93
  http.start do |host|
92
- http_response = yield(host)
94
+ http_response = nil
95
+ response_time = Benchmark.realtime do
96
+ http_response = yield(host)
97
+ end
98
+
93
99
  headers = []
94
100
  http_response.canonical_each do |*h|
95
101
  headers << h
@@ -97,7 +103,8 @@ private
97
103
  request.send :response=,
98
104
  HTTY::Response.new(:status => http_response_to_status(http_response),
99
105
  :headers => headers,
100
- :body => http_response.body)
106
+ :body => http_response.body,
107
+ :time => response_time)
101
108
  end
102
109
  request
103
110
  end
@@ -9,6 +9,9 @@ class HTTY::Response < HTTY::Payload
9
9
  # Returns the HTTP status associated with the response.
10
10
  attr_reader :status
11
11
 
12
+ # Returns a benchmark time to receive the response.
13
+ attr_reader :time
14
+
12
15
  # Initializes a new HTTY::Response with attribute values specified in the
13
16
  # _attributes_ hash.
14
17
  #
@@ -19,7 +22,8 @@ class HTTY::Response < HTTY::Payload
19
22
  # * <tt>:status</tt>
20
23
  def initialize(attributes={})
21
24
  super attributes
22
- @status = attributes[:status]
25
+ @status = attributes[:status]
26
+ @time = attributes[:time]
23
27
  @already_followed = false
24
28
  end
25
29
 
@@ -1,6 +1,6 @@
1
1
  module HTTY
2
2
 
3
3
  # The version of this release of _htty_.
4
- VERSION = '1.5.5'
4
+ VERSION = '1.5.7'
5
5
 
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: htty
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 1.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nils Jonsson
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-21 00:00:00.000000000 Z
11
+ date: 2015-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mime-types