Skip to content
This repository has been archived by the owner on Dec 27, 2022. It is now read-only.

Commit

Permalink
remove uncompressed data magic header
Browse files Browse the repository at this point in the history
default to returning uncompressed data without checking for magic header for
compliant with graylog2 server. Relevant piece for graylog2 server is at
https://github.com/Graylog2/graylog2-server/blob/edd1a66a2f9924e39b217df4c94327a86b8fecab/graylog2-server/src/main/java/org/graylog2/inputs/codecs/gelf/GELFMessage.java#L147

Signed-off-by: Daniel Dao <dqminh@cloudflare.com>
  • Loading branch information
dqminh committed Feb 11, 2016
1 parent 229cf5f commit bd3c3af
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions lib/gelfd/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ def self.parse(data)
ChunkedParser.parse(data)
when GZIP_MAGIC
GzipParser.parse(data)
when UNCOMPRESSED_MAGIC
data[2..-1]
else
raise UnknownHeaderError, "Could not find parser for header: #{header.unpack('C*').to_s}"
# by default assume the payload to be "raw, uncompressed" GELF, parsing will fail if it's malformed.
data
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/unchunked.uc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<{"this":"is","my":"boomstick"}
{"this":"is","my":"boomstick"}
2 changes: 1 addition & 1 deletion test/tc_uncompressed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class TestUncompressedGelf < Test::Unit::TestCase
FIXTURE_PATH = File.expand_path(File.join(File.dirname(__FILE__), 'fixtures'))

def test_uncompressed_message
data = File.open("#{FIXTURE_PATH}/unchunked.uc", "rb") {|f| f.read}
t = Gelfd::Parser.parse(data)
Expand Down

0 comments on commit bd3c3af

Please sign in to comment.