Override default, adding the capture of content and contenttype.
779616
def from_dict(cls, d):
        
        o = super(Signature, cls).from_dict(d)
        if 'content' in d:
            # Sometimes, several contents, (one txt, other  html), take last
            try:
                o._content = d['content']['_content']
                o._contenttype = d['content']['type']
            except TypeError:
                o._content = d['content'][-1]['_content']
                o._contenttype = d['content'][-1]['type']

        return o
191694
public void setContentType(MediaType mediaType) {
		Assert.isTrue(!mediaType.isWildcardType(), "'Content-Type' cannot contain wildcard type '*'");
		Assert.isTrue(!mediaType.isWildcardSubtype(), "'Content-Type' cannot contain wildcard subtype '*'");
		set(CONTENT_TYPE, mediaType.toString());
	}
848328
public static void put(String extension, String contentType) {
        if (extension != null && extension.length() != 0
                && contentType != null && contentType.length() != 0) {

            contentTypes.put(extension, contentType);
        }
    }
1304641
public void setContentType(String contentType)
  {
    _contentType = contentType;

    if (_contentType.equals("text/xml"))
      _strategy = XML;
    if (_contentType.equals("application/xml"))
      _strategy = XML;
    else if (_contentType.equals("text/xhtml"))
      _strategy = XHTML;
    else if (_contentType.equals("application/xhtml+xml"))
      _strategy = XHTML;
    else if (_contentType.equals("text/html"))
      _strategy = HTML;
    else
      _strategy = XML;
  }
500940
def choose_type(cls, content_type):
        """"""
        return cls.type_cls.SUBDIR if content_type in cls.subdir_types \
            else cls.type_cls.FILE
142064
def addStartTag(contents, startTag):
    '''
        
    '''

    matchObj = DOCTYPE_MATCH.match(contents)
    if matchObj:
        idx = matchObj.end()
    else:
        idx = 0
    return "%s\n%s\n%s" %(contents[:idx], startTag, contents[idx:])
810394
function addMedia(uri, contentType, safe) {
  if (!uri || uri === '') {
    return 'You must enter a valid uri'
  }
  safe = safe || 0
  return new Promise((resolve, reject) => {

    var config = require('../config/config.js')
    var conn = wc_db.getConnection(config.db)

    // sniff content type
    if (!contentType) {
      // image
      if (uri.indexOf('.jpg') !== -1) {
        contentType = 'image'
      }
      if (uri.indexOf('.png') !== -1) {
        contentType = 'image'
      }
      if (uri.indexOf('.gif') !== -1) {
        contentType = 'image'
      }
      if (uri.indexOf('.svg') !== -1) {
        contentType = 'image'
      }
      // video
      if (uri.indexOf('.mp4') !== -1) {
        contentType = 'video'
      }
      if (uri.indexOf('.mpg') !== -1) {
        contentType = 'video'
      }
      if (uri.indexOf('.mov') !== -1) {
        contentType = 'video'
      }
      if (uri.indexOf('.wmv') !== -1) {
        contentType = 'video'
      }
      if (uri.indexOf('.avi') !== -1) {
        contentType = 'video'
      }
      if (uri.indexOf('.m4v') !== -1) {
        contentType = 'video'
      }
      if (uri.indexOf('.mkv') !== -1) {
        contentType = 'video'
      }
      // audio
      if (uri.indexOf('.mp3') !== -1) {
        contentType = 'audio'
      }
      if (uri.indexOf('.ogg') !== -1) {
        contentType = 'video'
      }
      if (uri.indexOf('.flv') !== -1) {
        contentType = 'video'
      }
    }

    var sql = 'INSERT into Media values (NULL, :uri, NULL, NULL, NULL, :contentType, ' + safe + ')'

    conn.query(sql, { replacements: { "uri" : uri, "contentType" : contentType } }).then(function(ret){
      return resolve({"ret" : ret, "conn" : conn})
    }).catch(function(err) {
      return reject(err)
    })

  })

}
569973
def alter_body_by_content_type(body, content_type)
      return body unless body.is_a?(String)
      content_type_attrs = ApiHammer::ContentTypeAttrs.new(content_type)
      if @options[:text].nil? ? content_type_attrs.text? : @options[:text]
        if pretty?
          case content_type_attrs.media_type
          when 'application/json'
            require 'json'
            begin
              body = JSON.pretty_generate(JSON.parse(body))
            rescue JSON::ParserError
            end
          end
        end
        if color?
          coderay_scanner = CodeRayForMediaTypes.reject{|k,v| !v.any?{|type| type === content_type_attrs.media_type} }.keys.first
          if coderay_scanner
            require 'coderay'
            body = CodeRay.scan(body, coderay_scanner).encode(:terminal)
          end
        end
      else
        body = omitted_body("[[omitted binary body (size = #{body.size})]]")
      end
      body
    end
1142502
def add_content(self, data):
        # type: (Optional[Union[Dict[str, Any], ET.Element]]) -> None
        
        if data is None:
            return

        if isinstance(data, ET.Element):
            bytes_data = ET.tostring(data, encoding="utf8")
            self.headers['Content-Length'] = str(len(bytes_data))
            self.data = bytes_data
            return

        # By default, assume JSON
        try:
            self.data = json.dumps(data)
            self.headers['Content-Length'] = str(len(self.data))
        except TypeError:
            self.data = data
110964
def _addTags(self, **k):
        """"""

        for tag, thing in k.items():
            if not isinstance(thing, (tuple, list)):
                thing = (thing,)
            typetag = defaulttagtype[tag]
            self.rawtagdict[tag] = encode(typetag, *thing)
        return self
458878
public function enableHttpRequestParameterOverride()
    {
        if (is_int(stripos($_SERVER['CONTENT_TYPE'], 'application/json'))) {
            $content = (array)json_decode(file_get_contents("php://input"), true);
            $this->request->add($content);
        }
    }
1238686
def generate_content_media_type(self):
        
        if self._definition['contentMediaType'] == 'application/json':
            with self.l('if isinstance({variable}, bytes):'):
                with self.l('try:'):
                    self.l('{variable} = {variable}.decode("utf-8")')
                with self.l('except Exception:'):
                    self.l('raise JsonSchemaException("{name} must encoded by utf8")')
            with self.l('if isinstance({variable}, str):'):
                with self.l('try:'):
                    self.l('import json')
                    self.l('{variable} = json.loads({variable})')
                with self.l('except Exception:'):
                    self.l('raise JsonSchemaException("{name} must be valid JSON")')
102142
public Response andContentType(String contentType) {
        Objects.requireNonNull(contentType, Required.CONTENT_TYPE.toString());
        this.contentType = contentType;
        this.headers.put(Header.CONTENT_TYPE.toHttpString(), contentType);

        return this;
    }
1169763
def default_input_format(content_type='application/json', apply_globally=False, api=None):
    """"""
    def decorator(formatter):
        formatter = hug.output_format.content_type(content_type)(formatter)
        if apply_globally:
            hug.defaults.input_format[content_type] = formatter
        else:
            apply_to_api = hug.API(api) if api else hug.api.from_object(formatter)
            apply_to_api.http.set_input_format(content_type, formatter)
        return formatter
    return decorator
636471
public void setDefaultContentIndex(final Integer defaultContentIndex) {
        for (int i = 0; i < getContents().length; i++) {
            if (i == defaultContentIndex.intValue()) {
                getContents()[i].setDefaultContent(true);
            } else {
                getContents()[i].setDefaultContent(false);
            }
        }

        this.defaultContentIndex = defaultContentIndex;
    }
140245
def create_generic(self, content_object=None, **kwargs):
        
        if content_object:
            kwargs['content_type'] = ContentType.objects.get_for_model(
                content_object
            )
            kwargs['object_id'] = content_object.id

        return self.create(**kwargs)
420367
def put_content(self, content):
        

        self.blob.content_encoding = self.content_encoding
        self.blob.metadata = self.metadata
        return self.blob.upload_from_string(content, content_type=self.content_type)