Handle and process non-HTML responses.

@param {*} content
489060
function(content) {
        if (content.callback) {
            var namespaces = content.callback.split('.'),
                func = window, prev = func;

            for (var i = 0; i < namespaces.length; i++) {
                prev = func;
                func = func[namespaces[i]];
            }

            func.call(prev, content);
        }

        this.fireEvent('process', [content]);

        this.hide();
    }
893555
function handler(req,res){  
    try{
      res.writeHead(200, {'Content-Type': 'text/html'});
      var start = new Date().getTime();
      //console.log(start);

      //read css, wait.for syntax:
      var css = wait.for(fs.readFile,'style.css','utf8');

      //read post, fancy syntax:
      var content = wait.for(fs.readFile,'blogPost.txt','utf8');

      //compose  template, fancy syntax, as parameter:
      var template = composeTemplate ( css, wait.for(fs.readFile,'blogTemplate.html','utf8') );

      console.log('about to call hardToGetData...');

      //call async, wait.for syntax, in a expression
      var hardToGetData = "\n" + start.toString().substr(-5) +"<br>" + ( wait.for(longAsyncFn,'some data') );

      console.log('hardToGetData=',hardToGetData);
      
      var end = new Date().getTime();

      hardToGetData += ', after '+(end-start)+' ms<br>';
      hardToGetData += end.toString().substr(-5);

      res.end( applyTemplate(template, formatPost ( content + hardToGetData) ) );

    }
    catch(err){
      res.end('ERROR: '+err.message);
    }
  }
170777
def html(content, **kwargs):
    """"""
    if hasattr(content, 'read'):
        return content
    elif hasattr(content, 'render'):
        return content.render().encode('utf8')

    return str(content).encode('utf8')
318839
def process_response(self, request, response):
        """"""

        # For debug only.
        if not settings.DEBUG:
            return response

        # Check for responses where the data can't be inserted.
        content_encoding = response.get('Content-Encoding', '')
        content_type = response.get('Content-Type', '').split(';')[0]
        if any((getattr(response, 'streaming', False),
                'gzip' in content_encoding,
                content_type not in _HTML_TYPES)):
            return response

        content = force_text(response.content, encoding=settings.DEFAULT_CHARSET)

        pattern = re.escape('</body>')
        bits = re.split(pattern, content, flags=re.IGNORECASE)

        if len(bits) > 1:
            bits[-2] += debug_payload(request, response, self.view_data)
            response.content = "</body>".join(bits)
            if response.get('Content-Length', None):
                response['Content-Length'] = len(response.content)

        return response
337813
function getHTMLFromResponseBody(buffer, contentType) {
  const [mimeType, ...typeOptions]  = contentType.split(/;\s*/);

  // Pick charset from content type
  if (mimeType)
    for (let typeOption of typeOptions)
      if (/^charset=/i.test(typeOption)) {
        const charset = typeOption.split('=')[1];
        return iconv.decode(buffer, charset);
      }

  // Otherwise, HTML documents only, pick charset from meta tag
  // Otherwise, HTML documents only, default charset in US is windows-1252
  const charsetInMetaTag = buffer.toString().match(MATCH_CHARSET);
  if (charsetInMetaTag)
    return iconv.decode(buffer, charsetInMetaTag[1]);
  else
    return iconv.decode(buffer, 'windows-1252');
}
962153
@Override
    public void processOtherContent(Wrapper<Content> content) {
        if (processFirstOtherContent) {
            builder.append(baseIndent).append("otherContentList=").append("\n");
            processFirstOtherContent = false;
        }
        builder.append(content.toString(baseIndent)).append("\n");
    }
1303463
function processContentRequest(req, res, sessions, controllers, nonObjTemplatelogLevel) {

    let path = url.parse(req.originalUrl, true).query.path;

    establishServerSession(req, path, false, false, null, sessions, controllers,
        nonObjTemplatelogLevel).then(function zz(semotus) {
            if (typeof(semotus.objectTemplate.controller.onContentRequest) === 'function') {
                semotus.objectTemplate.controller.onContentRequest(req, res);
            }
        });
}
396364
function (content) {
            var contentType = content.contentType;

            if (contentType && contentType in this.contentProcessors) {
                return this.processContent(this.contentProcessors[contentType].processContent(content));
            }
            return content.value || "";
        }
1259348
def _ensure_html_header(response):
    # type: (Response) -> None
    
    content_type = response.headers.get("Content-Type", "")
    if not content_type.lower().startswith("text/html"):
        raise _NotHTML(content_type, response.request.method)
161230
function(data) {
    var h, headerArray, headers, i, l, len, o;
    headers = {};
    headerArray = data.getAllResponseHeaders().split('\r');
    for (l = 0, len = headerArray.length; l < len; l++) {
      i = headerArray[l];
      h = i.match(/^([^:]*?):(.*)$/);
      if (!h) {
        h = [];
      }
      h.shift();
      if (h[0] !== void 0 && h[1] !== void 0) {
        headers[h[0].trim()] = h[1].trim();
      }
    }
    o = {};
    o.content = {};
    o.content.data = data.responseText;
    o.headers = headers;
    o.request = {};
    o.request.url = this.invocationUrl;
    o.status = data.status;
    return o;
  }
680963
function handleDeletions() {
	return es.mapSync(f => {
		if (/\.ts$/.test(f.relative) && !f.contents) {
			f.contents = Buffer.from('');
			f.stat = { mtime: new Date() };
		}

		return f;
	});
}
1201611
function handleResponse(ctx, response) {
  ctx.body = response.body;
  ctx.status = response.status;
  ctx.set(response.headers);
}
149061
def _handle_response(response):
        
        if not response.ok:
            raise NeverBounceAPIError(response)
        if response.headers.get('Content-Type') == 'application/octet-stream':
            return response.iter_lines()

        try:
            resp = response.json()
        except ValueError:
             raise InvalidResponseError('Failed to handle the response content-type {}.'.format(
                 response.headers.get('Content-Type'))
             )
        if 'success' in resp and not resp['success']:
            if 'msg' in resp and resp['msg'] == 'Authentication failed':
                raise AccessTokenExpired
            else:
                raise NeverBounceAPIError(response)
        return resp
852682
function(content){

			var html = '';

			html += '<div class="ja_wrap '+backgroundClasses.join(' ')+'">'+
					'<div class="jAlert '+classes.join(' ')+ '" style="' +styles.join(' ')+ '" id="' +alert.id+ '">'+
					'<div>';

			if( alert.closeBtn )
			{
				html += 		"<div class='closejAlert ja_close";
				if( alert.closeBtnAlt )
				{
					html += ' ja_close_alt';
				}
                else if( alert.closeBtnRoundWhite )
                {
                    html += ' ja_close_round_white';
                }
                else if( alert.closeBtnRound )
                {
                    html += ' ja_close_round';
                }
				html += "'>&times;</div>"; //closejAlert has a close handler attached, ja_close is for styling
			}

			if( alert.title )
			{
				html += 		"<div class='ja_title'><div>"+alert.title+"</div></div>";
			}

			html += 			'<div class="ja_body">'+content;


			if( alert.btns )
			{
				html += 			'<div class="ja_btn_wrap ';

				if( alert.btnBackground )
				{
					html += 		'optBack';
				}

				html += 			'">';
			}

			if( typeof alert.btns[0] == 'object' )
			{
				$.each(alert.btns, function(index, btn){
					if( typeof btn == 'object' )
					{
						html += 		getBtnHTML(btn);
					}
				});
			}
			else if( typeof alert.btns == 'object' )
			{
				html += 				getBtnHTML(alert.btns);
			}
			else if( alert.btns )
			{
				console.log('jAlert Config Error: Incorrect value for btns (must be object or array of objects): '+alert.btns);
			}

			if( alert.btns )
			{
				html += 			'</div>';
			}

			html += 			'</div>'+
					'</div>'+
					'</div>'+
					'</div>';

			var alertHTML = $(html);

			if( alert.replaceOtherAlerts )
			{
                var alerts = $('.jAlert:visible');
                alerts.each(function(){
                    $(this).jAlert().closeAlert();
                });
			}

			$('body').append(alertHTML);

            //cache instance
			alert.instance = $('#'+alert.id);

            //attach alert object to dom element
            alert.instance[0]['jAlert'] = alert;

            //doing this now will prevent it from happening mid-animation
            $('html,body').css('overflow', 'hidden');

            //show the new alert
			alert.animateAlert('show');

            //add close button handler
			if( alert.closeBtn ){

				alert.instance.on('click', '.closejAlert', function(e){
					e.preventDefault();
					$(this).parents('.jAlert:first').jAlert().closeAlert();
					return false;
				});

			}

			/* Bind mouseup handler to document if this alert has closeOnClick enabled */
			if( alert.closeOnClick ){

				/* Unbind if already exists */
				$(document).off('mouseup touchstart', $.fn.jAlert.onMouseUp);

				/* Bind mouseup */
				$(document).on('mouseup touchstart', $.fn.jAlert.onMouseUp);

			}

			/* Bind on keydown handler to document and if esc was pressed, find all visible jAlerts with that close option enabled and close them */
			if( alert.closeOnEsc ){

				/* Unbind if already exists */
				$(document).off('keydown', $.fn.jAlert.onEscKeyDown);

				/* Bind keydown */
				$(document).on('keydown', $.fn.jAlert.onEscKeyDown);

			}

			/* If there are onOpen callbacks, run them. */
			if( alert.onOpen )
			{
				$.each(alert.onOpen, function(index, onOpen){
					onOpen(alert.instance);
				});
			}

			/* If the alert has an element that should be focused by default */
			if( alert.autofocus )
			{
				alert.instance.find(alert.autofocus).focus();
			}
			else
			{
				alert.instance.focus();
			}
            /*
            	Set Auto
            	usage $.jAlert({
            		autoClose : 3500,
            	});
             */
            if(alert.autoClose)
            {
                $.fn.closeTimer(function()
				{
                    var currentAlert = $.jAlert('current');
                    if(currentAlert !== false)
                    {
                        currentAlert.closeAlert();
                    }
				}, alert.autoClose);
            }

			return alert.instance;

		}
415047
function respondText(res, code, text) {
  res.statusCode = code;
  res.setHeader('Content-Type', 'text/plain');
  return res.end(text.toString());
}
507991
def from_post_response(post_response, content):
        '''
        
        '''
        response = OutcomeResponse()
        response.post_response = post_response
        response.response_code = post_response.status
        response.process_xml(content)
        return response
474657
def _handle_content(self, relpath, params):
    """"""
    abspath = os.path.normpath(os.path.join(self._root, relpath))
    if os.path.isfile(abspath):
      with open(abspath, 'rb') as infile:
        content = infile.read()
    else:
      content = 'No file found at {}'.format(abspath).encode('utf-8')
    content_type = mimetypes.guess_type(abspath)[0] or 'text/plain'
    if not content_type.startswith('text/') and not content_type == 'application/xml':
      # Binary file. Display it as hex, split into lines.
      n = 120  # Display lines of this max size.
      content = repr(content)[1:-1]  # Will escape non-printables etc, dropping surrounding quotes.
      content = '\n'.join([content[i:i + n] for i in range(0, len(content), n)])
      prettify = False
      prettify_extra_langs = []
    else:
      prettify = True
      if self._settings.assets_dir:
        prettify_extra_dir = os.path.join(self._settings.assets_dir, 'js', 'prettify_extra_langs')
        prettify_extra_langs = [{'name': x} for x in os.listdir(prettify_extra_dir)]
      else:
        # TODO: Find these from our package, somehow.
        prettify_extra_langs = []
    linenums = True
    args = {'prettify_extra_langs': prettify_extra_langs, 'content': content,
            'prettify': prettify, 'linenums': linenums}
    content = self._renderer.render_name('file_content.html', args).encode("utf-8")
    self._send_content(content, 'text/html')