zabbix_protocol 0.1.5.beta → 0.1.5.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zabbix_protocol/version.rb +1 -1
- data/lib/zabbix_protocol.rb +10 -1
- data/spec/zabbix_protocol_spec.rb +7 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ad71e098d1d6641e868186bbcb191fe022f36db
|
4
|
+
data.tar.gz: 2b49036eb5e410e380be019f7475103ea3752130
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8be4c0d4a6f51aab987d34c8641f0687ae2693d8344bfaa0e31e001a89917d32583916623afffa5e7f9a7ba5bc62531ba9abb390cdbbd2d4bbed469db458933
|
7
|
+
data.tar.gz: a8255c048e7a19d59423f69324aa33cf900709ac8cf42347a164763711a3cbb84e285bbabe85a874d69eff895d06b7541978c6f4a092294123138cdcf8d43824
|
data/lib/zabbix_protocol.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "multi_json"
|
2
|
-
|
3
2
|
require "zabbix_protocol/version"
|
4
3
|
|
5
4
|
module ZabbixProtocol
|
@@ -34,6 +33,7 @@ module ZabbixProtocol
|
|
34
33
|
raise TypeError, "wrong argument type #{data.class} (expected String)"
|
35
34
|
end
|
36
35
|
|
36
|
+
original_encoding = data.encoding
|
37
37
|
data = data.dup
|
38
38
|
data.force_encoding('ASCII-8BIT')
|
39
39
|
|
@@ -61,6 +61,15 @@ module ZabbixProtocol
|
|
61
61
|
raise Error, "invalid payload length: expected=#{payload_len}, actual=#{sliced.bytesize} (data: #{data.inspect})"
|
62
62
|
end
|
63
63
|
|
64
|
+
duplicated = sliced.dup
|
65
|
+
|
66
|
+
begin
|
67
|
+
duplicated.force_encoding(original_encoding)
|
68
|
+
sliced = duplicated
|
69
|
+
rescue
|
70
|
+
# XXX: nothing to do
|
71
|
+
end
|
72
|
+
|
64
73
|
begin
|
65
74
|
MultiJson.load(sliced)
|
66
75
|
rescue MultiJson::ParseError
|
@@ -59,6 +59,13 @@ describe ZabbixProtocol do
|
|
59
59
|
data = subject.load(res_data)
|
60
60
|
expect(data).to eq({"response"=>"success", "data"=>[]})
|
61
61
|
end
|
62
|
+
|
63
|
+
it "should parse string" do
|
64
|
+
res_data = "ZBXD\x01\x0f\x00\x00\x00\x00\x00\x00\x00response-string"
|
65
|
+
data = subject.load(res_data)
|
66
|
+
expect(data).to eq("response-string")
|
67
|
+
expect(data.encoding).to eq Encoding::UTF_8
|
68
|
+
end
|
62
69
|
end
|
63
70
|
|
64
71
|
context "when error happen" do
|