requests/utils.py
<<<<<<< SEARCH
def super_len(o):
    if hasattr(o, '__len__'):
        return len(o)
    if hasattr(o, 'len'):
        return o.len
    if hasattr(o, 'fileno'):
        return os.fstat(o.fileno()).st_size
=======
def super_len(o):
    from .compat import str as text_type

    if isinstance(o, text_type):
        try:
            return len(o.encode('utf-8'))
        except UnicodeError:
            return len(o)
    if hasattr(o, '__len__'):
        return len(o)
    if hasattr(o, 'len'):
        return o.len
    if hasattr(o, 'fileno'):
        return os.fstat(o.fileno()).st_size
>>>>>>> REPLACE
requests/models.py
<<<<<<< SEARCH
        elif data:
            body = self._encode_params(data)
            if isinstance(data, basestring) or hasattr(data, 'read'):
                content_type = None
            else:
                content_type = 'application/x-www-form-urlencoded'
=======
        elif data is not None:
            body = self._encode_params(data)
            if isinstance(body, str):
                try:
                    body = body.encode('utf-8')
                except UnicodeEncodeError:
                    pass
            if isinstance(data, basestring) or hasattr(data, 'read'):
                content_type = None
            else:
                content_type = 'application/x-www-form-urlencoded'
>>>>>>> REPLACE
requests/models.py
<<<<<<< SEARCH
        elif body is not None:
            l = super_len(body)
            if l:
                self.headers['Content-Length'] = builtin_str(l)

        # Add content-length if it is not there
        if 'Content-Length' not in self.headers:
            self.headers['Content-Length'] = '0'
=======
        elif body is not None:
            try:
                l = super_len(body)
            except UnicodeEncodeError:
                l = len(body) if hasattr(body, '__len__') else 0
            if l or hasattr(body, '__len__') or hasattr(body, 'len'):
                self.headers['Content-Length'] = builtin_str(l)

        # Add content-length if it is not there: only for methods that
        # carry a body. GET/HEAD with body=None omit it, an explicit
        # 'Content-Length' header set earlier is left untouched, and an
        # explicit empty body above already set it to '0'.
        if self.method not in ('GET', 'HEAD') and 'Content-Length' not in self.headers:
            self.headers['Content-Length'] = '0'
>>>>>>> REPLACE
requests/sessions.py
<<<<<<< SEARCH
            # Remove the cookie headers that were sent.
            headers = req.headers
            try:
                del headers['Cookie']
            except KeyError:
                pass
=======
            # Remove the cookie headers that were sent.
            headers = req.headers
            try:
                del headers['Cookie']
            except KeyError:
                pass

            if resp.status_code not in (307, 308) and req.method in ('GET', 'HEAD'):
                # This redirect drops the body (307/308 preserve it), so
                # do not leak the previous request's body headers into
                # the bodyless follow-up on a reused connection.
                for header in ('Content-Length', 'Content-Type', 'Transfer-Encoding'):
                    try:
                        del headers[header]
                    except KeyError:
                        pass
>>>>>>> REPLACE