import json

class BaseResponse(object):
    def __init__(self, obj=None):
        self.obj = obj

    @classmethod
    def create(cls, res=None, trace_id=None, streaming=False):
        resp = None

        if streaming:
            stream = res.iter_lines()
            first_line = next(stream)
            data = json.loads(first_line)
        else:
            if res.text:
                data = json.loads(res.text)
            else:
                data = None
        if streaming:
            resp = StreamResponse(obj=data['object'], stream=stream)
        elif data and 'object' in data:
            resp = ItemResponse(obj=data['object'])
        elif data and 'objects' in data:
            resp = ListResponse(obj=data['objects'])
        else:
            resp = NoItemResponse(obj=None)
        resp.trace_id = trace_id
        resp.res = res
        resp.data = data
        return resp

    def find_link(self, rel):
        for link in self.data.get('links', []):
            if link.get('rel') == rel:
                return link
        return None

class ListResponse(BaseResponse):
    @property
    def items(self):
        return self.obj

    @property
    def item(self):
        return self.obj[0]

class ItemResponse(BaseResponse):
    @property
    def items(self):
        return [self.obj]

    @property
    def item(self):
        return self.obj

class NoItemResponse(BaseResponse):
    @property
    def items(self):
        return None

    @property
    def item(self):
        return None

class StreamResponse(BaseResponse):
    def __init__(self, obj, stream):
        BaseResponse.__init__(self, obj)
        self._stream = stream

    @property
    def items(self):
        def stream():
            for line in self._stream:
                yield json.loads(line)['object']
        return stream()

    @property
    def item(self):
        return self.obj

@@ -6,16 +6,335 @@
 t json%0A%0A
+def bytes_to_lines(stream):%0A    %22%22%22Reads single bytes from stream, emits lines.%0A    %0A       This hack makes me sick, but requests makes this impossible%0A       to do reliably, otherwise.%22%22%22%0A    line = %22%22%0A    for byte in stream:%0A        line += byte%0A        if byte == %22%5Cn%22:%0A            yield line%0A            line = %22%22%0A%0A
 class Ba
@@ -559,23 +559,53 @@
 m = 
-res.iter_lines(
+bytes_to_lines(res.iter_content(chunk_size=1)
 )%0A  
@@ -825,32 +825,32 @@
   if streaming:%0A
-
             resp
@@ -854,24 +854,37 @@
 esp = Stream
+ingJsonObject
 Response(obj
@@ -1897,16 +1897,29 @@
 s Stream
+ingJsonObject
 Response

Work around requests' broken sense of streaming lines.