Get content-type from req/res objects.

@param {object}
@return {Object}
@private
6061
function getcontenttype(obj) {
  if (typeof obj.getHeader === 'function') {
    // res-like
    return obj.getHeader('content-type')
  }

  if (typeof obj.headers === 'object') {
    // req-like
    return obj.headers && obj.headers['content-type']
  }
}
293686
function(req, res){
		    return function(){
		        var buf = [],
		            messages = req.flash(),
		            types = Object.keys(messages),
		            len = types.length;
		        if (!len) {
		           return '';
	           }
		        buf.push('<div id="messages">');
		        for (var i = 0 ; i < len; ++i) {
		            var type = types[i],
		                msgs = messages[type], j;
		            buf.push('  <ul class="' + type + '">');
		            for (j = 0, len = msgs.length; j < len; ++j) {
		                var msg = msgs[j];
		                buf.push('    <li>' + msg + '</li>');
		            }
		            buf.push('  </ul>');
		        }
		        buf.push('</div>');
		        return buf.join('\n');
		    };
		}
712227
def select_header_content_type(self, content_types):
        
        if not content_types:
            return 'application/json'

        content_types = [x.lower() for x in content_types]

        if 'application/json' in content_types or '*/*' in content_types:
            return 'application/json'
        else:
            return content_types[0]
1188430
def get_content_json(request):
    """"""
    result = _get_content_json()

    resp = request.response
    resp.status = "200 OK"
    resp.content_type = 'application/json'
    resp.body = json.dumps(result)
    return result, resp
422819
function json (request) {

    var type = request.headers.get('Content-Type') || '';

    if (isObject(request.body) && type.indexOf('application/json') === 0) {
        request.body = JSON.stringify(request.body);
    }

    return function (response) {

        return response.bodyText ? when(response.text(), function (text) {

            var type = response.headers.get('Content-Type') || '';

            if (type.indexOf('application/json') === 0 || isJson(text)) {

                try {
                    response.body = JSON.parse(text);
                } catch (e) {
                    response.body = null;
                }

            } else {
                response.body = text;
            }

            return response;

        }) : response;

    };
}
319018
function getReqObj(url, obj){
  if(typeof url === 'object') return url;
  else {
    obj = {}
    obj.url = url
    return obj
  }
}
516718
def get_content_type(name, content):
    
    if hasattr(content, "content_type"):
        content_type = content.content_type
    else:
        mime_type, encoding = mimetypes.guess_type(name)
        content_type = mime_type
    return content_type
44200
def get_content_type(*names):
    """"""
    for name in names:
        if name is not None:
            mimetype, encoding = mimetypes.guess_type(name)
            if mimetype is not None:
                if isinstance(mimetype, bytes):
                    return mimetype.decode("ascii")
                else:
                    return mimetype
    else:
        return "application/octet-stream"
846842
def smart_content_type(self):
        """"""
        content_type = self.content_type
        if content_type in (None, '', 'application/octet-stream'):
            content_type, _ = mimetypes.guess_type(self.name)

        return content_type
119674
private ContentType getContentType() {
        String contentTypeValue = m_request.getContentType();
        if (contentTypeValue == null) {
            return ContentType.TEXT_XML;
        }
        return new ContentType(contentTypeValue);
    }
1107349
def _object_type_html(self):
        

        if self.exists:
            return "<a href=\"%s\">%s</a>" % (self.url(), 
                                              self.content_type.name,)
        else:
            return "<s>%s</s>" % self.content_type.name
489842
function(req, res, next) {
        var parsed = require("url").parse(req.url);
        if (parsed.pathname.match(/\.less$/)) {
            return less(parsed.pathname).then(function(o) {
                res.setHeader("Content-Type", "text/css");
                res.end(o.css);
            });
        }
        next();
    }
26602
function(type) {
    if (typeof XMLHttpRequest == 'undefined') {
      return false;
    }
    var xhr = new XMLHttpRequest();
    xhr.open('get', '/', true);
    try {
      xhr.responseType = type;
    } catch(error) {
      return false;
    }
    return 'response' in xhr && xhr.responseType == type;
  }
835907
def on_content_type(handlers, default=None, error='The requested content type does not match any of those allowed'):
    
    def output_type(data, request, response):
        handler = handlers.get(request.content_type.split(';')[0], default)
        if not handler:
            raise falcon.HTTPNotAcceptable(error)

        response.content_type = handler.content_type
        return handler(data, request=request, response=response)
    output_type.__doc__ = 'Supports any of the following formats: {0}'.format(', '.join(
        function.__doc__ or function.__name__ for function in handlers.values()))
    output_type.content_type = ', '.join(handlers.keys())
    return output_type
867358
def content_type(type = nil, params={})
      return response['Content-Type'] unless type
      default = params.delete :default
      mime_type = mime_type(type) || default
      fail "Unknown media type: %p" % type if mime_type.nil?
      mime_type = mime_type.dup
      unless params.include? :charset or settings.add_charset.all? { |p| not p === mime_type }
        params[:charset] = params.delete('charset') || settings.default_encoding
      end
      params.delete :charset if mime_type.include? 'charset'
      unless params.empty?
        mime_type << (mime_type.include?(';') ? ', ' : ';')
        mime_type << params.map { |kv| kv.join('=') }.join(', ')
      end
      response['Content-Type'] = mime_type
    end
420736
def get_content_type(self):
        """"""
        ctype = self.part.get_content_type()
        # replace underspecified mime description by a better guess
        if ctype in ['octet/stream', 'application/octet-stream',
                     'application/octetstream']:
            ctype = guess_mimetype(self.get_data())
        return ctype
171411
function parseContentTypeHeader ( str ) {
	if ( /charset=$/.test(str) ) {
		str = `${str}utf8`;
	}
	return contentType.parse(str);
}