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 +4 -4
- data/History.markdown +7 -0
- data/lib/htty.rb +3 -1
- data/lib/htty/cli/commands/help.rb +1 -6
- data/lib/htty/cli/commands/path_set.rb +6 -6
- data/lib/htty/cli/commands/query_add.rb +1 -0
- data/lib/htty/cli/commands/query_set.rb +1 -0
- data/lib/htty/cli/display.rb +4 -3
- data/lib/htty/cli/http_method_command.rb +1 -0
- data/lib/htty/requests_util.rb +9 -2
- data/lib/htty/response.rb +5 -1
- data/lib/htty/version.rb +1 -1
- 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: bef059d23fabb8977b1c724590cd62bc1a164a4a
|
4
|
+
data.tar.gz: 08bb998dbc5f51f8f102ec0b0917b6efd114e046
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1245d3eac192a6abdcfcefe47b881ce9dfa2ad8553e1b4b536c23e2da540ae1d75224d9a33e1a8a28b23ea93d7b5538d6011942921953e78ba59db1681b0cdb0
|
7
|
+
data.tar.gz: c0e6f2da76971ed227013b3a8f3c81b2b2f999cbbc2b38d35c6e28c1c3507faf65705cee98758179fbb9d03d8b1fa48ef804356414691995bcbffe46393ddc9c
|
data/History.markdown
CHANGED
@@ -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
|
|
data/lib/htty.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
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)
|
data/lib/htty/cli/display.rb
CHANGED
@@ -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
|
157
|
-
body_size
|
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)
|
data/lib/htty/requests_util.rb
CHANGED
@@ -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 =
|
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
|
data/lib/htty/response.rb
CHANGED
@@ -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
|
25
|
+
@status = attributes[:status]
|
26
|
+
@time = attributes[:time]
|
23
27
|
@already_followed = false
|
24
28
|
end
|
25
29
|
|
data/lib/htty/version.rb
CHANGED
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.
|
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
|
11
|
+
date: 2015-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mime-types
|