Will then be an option to :

> -        body = obj.body
> -        if isinstance(body, str):
> -            return body.decode('utf-8') if unicode else body
> -        return body if unicode else body.encode('utf-8')
> +        return body obj.body

Does this make any sense?



2013/11/20 Daniel Graña <notifications@github.com>

> In scrapy/utils/response.py:
>
> >          return obj.body_as_unicode() if unicode else obj.body
> > +    elif isinstance(obj, Response):
> > +        body = obj.body
> > +        if isinstance(body, str):
> > +            return body.decode('utf-8') if unicode else body
> > +        return body if unicode else body.encode('utf-8')
>
> I must admit there is nothing useful on those headers :)
>
> body_as_str is only used in scrapy.utils.iterators, I am temped to move
> it there as a private function.
>
> And in that case may be assume UTF-8 in case of unknown encoding for
> Response.
>
> Another option is to retry detection based on body content with
> responsetypes.from_args(body=response.body), I am not sure why this is
> not done in http handlers.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/scrapy/scrapy/pull/462/files#r7767231>
> .
>