http_streaming_client 0.9.7 → 0.9.8
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 +4 -4
- data/lib/http_streaming_client/client.rb +1 -1
- data/lib/http_streaming_client/decoders/gzip.rb +29 -6
- data/lib/http_streaming_client/oauth/adobe.rb +7 -2
- data/lib/http_streaming_client/version.rb +1 -1
- data/spec/adobe_spec.rb +1 -1
- data/spec/client_spec.rb +1 -1
- data/spec/twitter_spec.rb +1 -0
- 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: d5581509d2fd5ef9ceb88108f0dab57b572aa127
|
4
|
+
data.tar.gz: 8d3203d98d53c23839eb475b05c66767ea44477e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 959b75f1f05b14c47d6ec4f0f38a7d66c3d5d6b0734fc1314c017840fff333499bbc99c6697f4aa89cc1151a77347395f6a6674b10ccfa0f4f7c3b31933bc783
|
7
|
+
data.tar.gz: c000c10712d472eebfabfefdac34a1ebc54feca247e9efb51d39ca0af4a116d179983e79ea63e735888ac18aee2d7cb58716528d74c3216984ee4c515808d59c
|
@@ -426,7 +426,7 @@ module HttpStreamingClient
|
|
426
426
|
|
427
427
|
if uri.scheme.eql? "https"
|
428
428
|
ctx = OpenSSL::SSL::SSLContext.new
|
429
|
-
|
429
|
+
ctx.set_params(verify_mode: OpenSSL::SSL::VERIFY_PEER)
|
430
430
|
@socket = OpenSSL::SSL::SSLSocket.new(@socket, ctx).tap do |socket|
|
431
431
|
socket.sync_close = true
|
432
432
|
socket.connect
|
@@ -60,10 +60,10 @@ module HttpStreamingClient
|
|
60
60
|
return unless compressed_packet && compressed_packet.size > 0
|
61
61
|
@buf ||= GZipBufferIO.new
|
62
62
|
@buf << compressed_packet
|
63
|
+
@gzip ||= Zlib::GzipReader.new @buf
|
63
64
|
|
64
65
|
# pass at least GZIP_READER_MIN_BUF_SIZE bytes to GzipReader to avoid zlib EOF
|
65
66
|
while @buf.size > GZIP_READER_MIN_BUF_SIZE do
|
66
|
-
@gzip ||= Zlib::GzipReader.new @buf
|
67
67
|
decompressed_packet = nonblock_readline(@gzip)
|
68
68
|
#logger.debug "GZip:<<:decompressed_packet:#{decompressed_packet}"
|
69
69
|
break if decompressed_packet.nil?
|
@@ -73,14 +73,16 @@ module HttpStreamingClient
|
|
73
73
|
|
74
74
|
def close
|
75
75
|
logger.debug "GZip:close"
|
76
|
+
return if @buf.size == 0
|
77
|
+
|
76
78
|
decompressed_packet = ""
|
77
79
|
begin
|
78
80
|
@gzip ||= Zlib::GzipReader.new @buf
|
79
81
|
|
80
82
|
while true do
|
81
|
-
decompressed_packet = nonblock_readline(@gzip)
|
82
|
-
|
83
|
-
break if decompressed_packet.nil?
|
83
|
+
decompressed_packet = nonblock_readline(@gzip, true)
|
84
|
+
logger.debug "GZip:close:decompressed_packet:#{decompressed_packet}"
|
85
|
+
break if decompressed_packet.nil? or decompressed_packet.size == 0
|
84
86
|
process_decompressed_packet(decompressed_packet)
|
85
87
|
end
|
86
88
|
|
@@ -93,7 +95,7 @@ module HttpStreamingClient
|
|
93
95
|
@buf.size
|
94
96
|
end
|
95
97
|
|
96
|
-
def nonblock_readline(io)
|
98
|
+
def nonblock_readline(io, on_close = false)
|
97
99
|
@line_buffer ||= ""
|
98
100
|
ch = nil
|
99
101
|
begin
|
@@ -106,17 +108,38 @@ module HttpStreamingClient
|
|
106
108
|
end
|
107
109
|
end
|
108
110
|
rescue Zlib::GzipFile::Error
|
109
|
-
# this is raised on EOF by ZLib in MRI
|
111
|
+
# this is raised on EOF by ZLib in MRI
|
112
|
+
# if we get here via a call to close(), then we want to return the line_buffer
|
113
|
+
# if we get here via any other path, we want to return nil to signal temporary EOF and leave the partial line_buffer contents in place.
|
110
114
|
logger.debug "Gzip:nonblock_readline:Zlib::GzipFile::Error:line_buffer.size:#{@line_buffer.size}"
|
115
|
+
if on_close then
|
116
|
+
result = @line_buffer
|
117
|
+
@line_buffer = ""
|
118
|
+
return result
|
119
|
+
end
|
111
120
|
return nil
|
112
121
|
rescue IOError
|
113
122
|
# this is raised on EOF by ZLib in JRuby, return nil to indicate EOF and leave partial line in the buffer
|
123
|
+
# if we get here via a call to close(), then we want to return the line_buffer
|
124
|
+
# if we get here via any other path, we want to return nil to signal temporary EOF and leave the partial line_buffer contents in place.
|
114
125
|
logger.debug "Gzip:nonblock_readline:IOError:line_buffer.size:#{@line_buffer.size}"
|
126
|
+
if on_close then
|
127
|
+
result = @line_buffer
|
128
|
+
@line_buffer = ""
|
129
|
+
return result
|
130
|
+
end
|
115
131
|
return nil
|
116
132
|
rescue => e
|
117
133
|
logger.debug "Gzip:nonblock_readline:error received:#{e.class}:#{e}"
|
118
134
|
raise e
|
119
135
|
end
|
136
|
+
|
137
|
+
if on_close then
|
138
|
+
result = @line_buffer
|
139
|
+
@line_buffer = ""
|
140
|
+
return result
|
141
|
+
end
|
142
|
+
|
120
143
|
end
|
121
144
|
|
122
145
|
protected
|
@@ -61,8 +61,13 @@ module HttpStreamingClient
|
|
61
61
|
url_string = "#{uri.scheme}://#{uri.host}#{uri.path}"
|
62
62
|
|
63
63
|
# POST to uri
|
64
|
-
|
65
|
-
|
64
|
+
assembled_response = ""
|
65
|
+
response = HttpStreamingClient::Client.post(uri, params_string, {:headers => {'Authorization' => "Basic #{basicAuth}"}}) { |line|
|
66
|
+
# token server now sending chunked, gzip'd response...
|
67
|
+
logger.debug "line received: #{line}"
|
68
|
+
assembled_response << line
|
69
|
+
}
|
70
|
+
response_json = JSON.parse(assembled_response)
|
66
71
|
|
67
72
|
logger.debug "token API response: #{response_json}"
|
68
73
|
|
data/spec/adobe_spec.rb
CHANGED
@@ -63,7 +63,7 @@ describe HttpStreamingClient do
|
|
63
63
|
|
64
64
|
end
|
65
65
|
|
66
|
-
describe "adobe firehose streaming get test, GZIP
|
66
|
+
describe "adobe firehose streaming get test, GZIP compression, authorization options factory" do
|
67
67
|
|
68
68
|
line_count = 0
|
69
69
|
|
data/spec/client_spec.rb
CHANGED
@@ -11,7 +11,7 @@ describe HttpStreamingClient do
|
|
11
11
|
|
12
12
|
describe "client instance get test, no chunked transfer encosing and GZIP compression" do
|
13
13
|
client = HttpStreamingClient::Client.new
|
14
|
-
response = client.get "
|
14
|
+
response = client.get "https://screamradius.com/"
|
15
15
|
logger.debug "response: #{response}"
|
16
16
|
subject { response }
|
17
17
|
it { should_not be_nil}
|
data/spec/twitter_spec.rb
CHANGED
@@ -49,6 +49,7 @@ describe HttpStreamingClient do
|
|
49
49
|
response = client.get(url, {:headers => {'Authorization' => "#{authorization}" }}) { |line|
|
50
50
|
count = count + 1
|
51
51
|
if count > NUM_JSON_RECORDS_TO_RECEIVE then
|
52
|
+
logger.debug "#{NUM_JSON_RECORDS_TO_RECEIVE} records received, interrupting..."
|
52
53
|
client.interrupt
|
53
54
|
next
|
54
55
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http_streaming_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Tompkins
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|