diff options
author | Eric Avdey <eiri@eiri.ca> | 2019-01-21 16:36:30 -0400 |
---|---|---|
committer | Eric Avdey <eiri@eiri.ca> | 2019-01-21 17:15:17 -0400 |
commit | 666ae213277102bb2ab8399cab10b614643cb67a (patch) | |
tree | dcabce856f3dd734d4747e60173bf733281d1815 | |
parent | 33e36254d787b38af7144b37fbb83783723a794a (diff) | |
download | couchdb-666ae213277102bb2ab8399cab10b614643cb67a.tar.gz |
Don't crash test on a response without Content-Type
Some GET responses (e.g. 304 Not Modified) should not generate
representation metadata (e.g. Content-Type) as per rfc7232.
This fix allows to process such requests without crashing process response
on a regexp over nil.
-rw-r--r-- | test/elixir/lib/couch.ex | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/test/elixir/lib/couch.ex b/test/elixir/lib/couch.ex index 934262216..97a0f9b0e 100644 --- a/test/elixir/lib/couch.ex +++ b/test/elixir/lib/couch.ex @@ -100,7 +100,9 @@ defmodule Couch do end def process_response_body(headers, body) do - if String.match?(headers[:"Content-Type"], ~r/application\/json/) do + content_type = headers[:"Content-Type"] + + if !!content_type and String.match?(content_type, ~r/application\/json/) do body |> IO.iodata_to_binary() |> :jiffy.decode([:return_maps]) else process_response_body(body) |