cdent / gabbi

Declarative HTTP Testing for Python and anything else
http://gabbi.readthedocs.org/
Other
148 stars 34 forks source link

Error when response content-type is application/jsonlines #296

Closed cdent closed 3 years ago

cdent commented 3 years ago

If the response is application/jsonlines the JSON content handler kicks in and attempts to decode the response from json, which fails as it treats the whole doc as one single json object, not lines of json.

This is because the accept method for the handler is checking for a content type that starts with 'application/json'

So the simple fix is straightforward, but it might make better sense to create a jsonlines response handler and see if we can make a way to jsonpath on those lines.

cdent commented 3 years ago

If a jsonlines response handler is created, it should be a separate package.

cdent commented 3 years ago

To complicate matters, it turns out there is an emerging way to present streaming json objects, popularized (by not pioneered) by kubernetes "watch" style requests:

Transfer-Encoding: chunked
Content-Type: application/json;stream=watch

[one object per chunk]

This is super easy to parse with python requests, lots of the various stream json processors, etc, so it's not going to go away.

But there are some issues with it:

I'm trying the second option, just to see...

cdent commented 3 years ago

I'm trying the second option, just to see...

works but seems a weak solution