httpx 0.1.0 → 0.2.0

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.
@@ -108,7 +108,14 @@ module HTTPX
108
108
 
109
109
  def to_s
110
110
  rewind
111
- return @buffer.read.force_encoding(@encoding) if @buffer
111
+ if @buffer
112
+ content = @buffer.read
113
+ begin
114
+ return content.force_encoding(@encoding)
115
+ rescue ArgumentError # ex: unknown encoding name - utf
116
+ return content
117
+ end
118
+ end
112
119
  ""
113
120
  ensure
114
121
  close
@@ -1,6 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class HTTPX::Selector
4
+ READABLE = %i[rw r].freeze
5
+ WRITABLE = %i[rw w].freeze
6
+
7
+ private_constant :READABLE
8
+ private_constant :WRITABLE
9
+
4
10
  #
5
11
  # I/O monitor
6
12
  #
@@ -15,11 +21,11 @@ class HTTPX::Selector
15
21
  end
16
22
 
17
23
  def readable?
18
- @interests == :rw || @interests == :r
24
+ READABLE.include?(@interests)
19
25
  end
20
26
 
21
27
  def writable?
22
- @interests == :rw || @interests == :w
28
+ WRITABLE.include?(@interests)
23
29
  end
24
30
 
25
31
  # closes +@io+, deregisters from reactor (unless +deregister+ is false)
@@ -60,8 +66,8 @@ class HTTPX::Selector
60
66
 
61
67
  # register +io+ for +interests+ events.
62
68
  def register(io, interests)
63
- readable = interests == :r || interests == :rw
64
- writable = interests == :w || interests == :rw
69
+ readable = READABLE.include?(interests)
70
+ writable = WRITABLE.include?(interests)
65
71
  @lock.synchronize do
66
72
  if readable
67
73
  monitor = @readers[io]
data/lib/httpx/timeout.rb CHANGED
@@ -11,7 +11,7 @@ module HTTPX
11
11
  super
12
12
  end
13
13
 
14
- def initialize(loop_timeout: 5, total_timeout: nil)
14
+ def initialize(loop_timeout: LOOP_TIMEOUT, total_timeout: nil)
15
15
  @loop_timeout = loop_timeout
16
16
  @total_timeout = total_timeout
17
17
  reset_counter
data/lib/httpx/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTTPX
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpx
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Cardoso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-04 00:00:00.000000000 Z
11
+ date: 2018-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-2
@@ -96,6 +96,7 @@ files:
96
96
  - lib/httpx/io.rb
97
97
  - lib/httpx/io/ssl.rb
98
98
  - lib/httpx/io/tcp.rb
99
+ - lib/httpx/io/udp.rb
99
100
  - lib/httpx/io/unix.rb
100
101
  - lib/httpx/loggable.rb
101
102
  - lib/httpx/options.rb
@@ -118,6 +119,12 @@ files:
118
119
  - lib/httpx/plugins/stream.rb
119
120
  - lib/httpx/registry.rb
120
121
  - lib/httpx/request.rb
122
+ - lib/httpx/resolver.rb
123
+ - lib/httpx/resolver/https.rb
124
+ - lib/httpx/resolver/native.rb
125
+ - lib/httpx/resolver/options.rb
126
+ - lib/httpx/resolver/resolver_mixin.rb
127
+ - lib/httpx/resolver/system.rb
121
128
  - lib/httpx/response.rb
122
129
  - lib/httpx/selector.rb
123
130
  - lib/httpx/timeout.rb