# Path: restkit/conn.py
# CHUNK_SIZE = 16 * 1024
# MAX_BODY = 1024 * 112
# DNS_TIMEOUT = 60
# class Connection(Connector):
#     def __init__(self, host, port, backend_mod=None, pool=None,
#             is_ssl=False, extra_headers=[], proxy_pieces=None, timeout=None,
#             **ssl_args):
#     def matches(self, **match_options):
#     def is_connected(self):
#     def handle_exception(self, exception):
#     def get_lifetime(self):
#     def invalidate(self):
#     def release(self, should_close=False):
#     def close(self):
#     def socket(self):
#     def send_chunk(self, data):
#     def send(self, data, chunked=False):
#     def sendlines(self, lines, chunked=False):
#     def sendfile(self, data, chunked=False):
#     def recv(self, size=1024):


import copy
import os
import tempfile
    from cStringIO import StringIO
    from StringIO import StringIO
from restkit import conn
        return dest.getvalue()

class ResponseTeeInput(TeeInput):

    CHUNK_SIZE = conn.CHUNK_SIZE

    def __init__(self, resp, connection, should_close=False):
        self.buf = StringIO()
        self.resp = resp
        self.stream =resp.body_stream()
        self.connection = connection
        self.should_close = should_close
        self.eof = False

        # set temporary body
        clen = int(resp.headers.get('content-length') or -1)
        if clen >= 0:
            if (clen <= conn.MAX_BODY):
                self.tmp = StringIO()
            else:
                self.tmp = tempfile.TemporaryFile()
        else:
            self.tmp = tempfile.TemporaryFile()

    def close(self):
        if not self.eof:
            # we didn't read until the end
            self._close_unreader()
        return self.tmp.close()


# Path: restkit/conn.py
# CHUNK_SIZE = 16 * 1024
# MAX_BODY = 1024 * 112
# DNS_TIMEOUT = 60
# class Connection(Connector):
#     def __init__(self, host, port, backend_mod=None, pool=None,
#             is_ssl=False, extra_headers=[], proxy_pieces=None, timeout=None,
#             **ssl_args):
#     def matches(self, **match_options):
#     def is_connected(self):
#     def handle_exception(self, exception):
#     def get_lifetime(self):
#     def invalidate(self):
#     def release(self, should_close=False):
#     def close(self):
#     def socket(self):
#     def send_chunk(self, data):
#     def send(self, data, chunked=False):
#     def sendlines(self, lines, chunked=False):
#     def sendfile(self, data, chunked=False):
#     def recv(self, size=1024):


# Path: restkit/tee.py
import copy
import os
import tempfile
    from cStringIO import StringIO
    from StringIO import StringIO
from restkit import conn

        return dest.getvalue()

class ResponseTeeInput(TeeInput):

    CHUNK_SIZE = conn.CHUNK_SIZE

    def __init__(self, resp, connection, should_close=False):
        self.buf = StringIO()
        self.resp = resp
        self.stream =resp.body_stream()
        self.connection = connection
        self.should_close = should_close
        self.eof = False

        # set temporary body
        clen = int(resp.headers.get('content-length') or -1)
        if clen >= 0:
            if (clen <= conn.MAX_BODY):
                self.tmp = StringIO()
            else:
                self.tmp = tempfile.TemporaryFile()
        else:
            self.tmp = tempfile.TemporaryFile()

    def close(self):
        if not self.eof:
            # we didn't read until the end
            self._close_unreader()
        return self.tmp.close()


    def _close_unreader(self):