Change response enconding and replace it by a HTMLResponse.
764876
def response_hook(response, **kwargs) -> XMLResponse:
        
        response.encoding = DEFAULT_ENCODING
        return XMLResponse._from_response(response)
330284
def ProcessHttpResponse(self, method_config, http_response, request=None):
        """"""
        return self.__client.ProcessResponse(
            method_config,
            self.__ProcessHttpResponse(method_config, http_response, request))
856846
def set_response_content_type(self):
        
        if self.response.body:
            ct = self.type
            if self.charset:
                ct += '; charset=' + self.charset
            self.response.headers['Content-Type'] = ct
        elif 'Content-Type' in self.response.headers:
            del self.response.headers['Content-Type']
812649
def _adapt_response(self, response):
        """"""
        if 'application/json' in response.headers['content-type']:
            body = response.json()
            status = response.status_code

            if body.get('error'):
                return self._simple_response_to_error_adapter(status, body)

        raise UnknownHttpError(response)
504615
def process_response(self, request, response, spider):
        """"""
        return response.replace(body=str(BeautifulSoup(response.body, self.parser)))
919933
def html(body, status=200, headers=None):
    '''
    
    '''
    return HTTPResponse(body, status=status, headers=headers,
                        content_type='text/html; charset=utf-8')
171066
def update(self):
        """"""
        response = self.jss.session.post(self.url, data=self.auth)
        response_xml = ElementTree.fromstring(response.text.encode("utf_8"))

        # Remove previous data, if any, and then add in response's XML.
        self.clear()
        for child in response_xml.getchildren():
            self.append(child)
1209896
protected function modifyResponse(array $response = array())
    {
        if (!empty($response['html'])) {
            $spam = array('~<p>(?:.*)</p>~i', '~<div (?:.*)</div>~i');
            $response['html'] = preg_replace($spam, '', $response['html']);
        }

        return $response;
    }
882101
protected function modifyResponse(array $response = array())
    {
        if (!empty($response['html']))
        {
            $response['html'] = str_replace('#{root_url}', 'https://www.scribd.com/', $response['html']);
            $response['html'] = preg_replace('~\s+~i', ' ', $response['html']); // Remove double spaces
        }

        return $response;
    }
753550
public void copyToResponse(HttpServletResponse response, byte[] alteredResponse) throws IOException {
        // character encoding
        if(this.characterEncoding != null) {
            response.setCharacterEncoding(this.characterEncoding);
        }

        // charset
        if(this.charset != null) {
            response.setCharacterEncoding(charset);
        }

        // content type
        if(this.contentType != null) {
            response.setContentType(this.contentType);
        }

        // set the status
        if(this.statusCode > 0) {
            response.setStatus(this.statusCode);
        }

        // set the locale
        if(this.locale != null) {
            response.setLocale(this.locale);
        }

        // copy and add all cookies
        if(this.cookies != null) {
            for(Cookie cookie : this.cookies) {
                response.addCookie(cookie);
            }
        }

        // copy the byte array stream and also set its length
        final OutputStream finalOut = response.getOutputStream();
        if(alteredResponse == null) {
            int length = this.outputStream.getLength();
            response.setContentLength(length);

            // write the entire byte chunk
            this.outputStream.getByteArrayOutputStream().writeTo(finalOut);
        } else {
            response.setContentLength(alteredResponse.length);
            finalOut.write(alteredResponse);
        }

        finalOut.flush();
    }
432414
def new_from_response(cls, response):
        
        return cls(response.url, html=response.text, headers=response.headers)
1128425
def __ProcessResponse(self, response):
        """"""
        if response.status_code not in self._ACCEPTABLE_STATUSES:
            # We distinguish errors that mean we made a mistake in setting
            # up the transfer versus something we should attempt again.
            if response.status_code in (http_client.FORBIDDEN,
                                        http_client.NOT_FOUND):
                raise exceptions.HttpError.FromResponse(response)
            else:
                raise exceptions.TransferRetryError(response.content)
        if response.status_code in (http_client.OK,
                                    http_client.PARTIAL_CONTENT):
            try:
                self.stream.write(six.ensure_binary(response.content))
            except TypeError:
                self.stream.write(six.ensure_text(response.content))
            self.__progress += response.length
            if response.info and 'content-encoding' in response.info:
                # TODO(craigcitro): Handle the case where this changes over a
                # download.
                self.__encoding = response.info['content-encoding']
        elif response.status_code == http_client.NO_CONTENT:
            # It's important to write something to the stream for the case
            # of a 0-byte download to a file, as otherwise python won't
            # create the file.
            self.stream.write('')
        return response
1180006
public static void makeStringResponse(HttpResponse response, String s) {
        StringEntity entity = new StringEntity(s, ContentType.TEXT_PLAIN);
        entity.setContentEncoding("utf-8");
        response.setEntity(entity);
    }
510815
def make_response(body, mimetype='text/html'):
    
    from werkzeug.wrappers import Response
    if isinstance(body, Response):
        body.mimetype = mimetype
        return body
    return Response(body, mimetype=mimetype)
1005110
def replace(self, src):
        ""
        for html in self.substitutions.keys():
            if src == html:
                annotation = self.annotation % self.substitutions[src][1]
                return annotation + self.substitutions[src][0]
        return src
498422
public HttpClientResponseBuilder doReturn(String response, Charset charset) {
        newRule.addAction(new StringResponse(response, charset));
        return new HttpClientResponseBuilder(newRule);
    }
770509
def transform(request, syntax_processor_name=None, var_name="text"):
    
    if request.method != 'POST':
        return HttpResponseNotAllowed("Only POST allowed")

    source = request.POST.get(var_name)
    if not source:
        return HttpResponse('')

    processor = TextProcessor.objects.get(name=syntax_processor_name or getattr(settings, "DEFAULT_MARKUP", "markdown"))
    output = processor.convert(source)

    try:
        t = template.Template(output, name='markup_preview')
        output = t.render(template.Context({'MEDIA_URL' : settings.MEDIA_URL}))
    except template.TemplateSyntaxError, e:
        log.warning('Error in preview rendering: %s' % e)
        output = '<h3 style="color:red">%s</h3><p>%s</p>' % (ugettext('You have an errors in source text!'), e)

    return HttpResponse(output)