Deserialize the data based on request content type headers
342847
def deserialize(self, data):
        '''
        
        '''
        ct_in_map = {
            'application/x-www-form-urlencoded': self._form_loader,
            'application/json': salt.utils.json.loads,
            'application/x-yaml': salt.utils.yaml.safe_load,
            'text/yaml': salt.utils.yaml.safe_load,
            # because people are terrible and don't mean what they say
            'text/plain': salt.utils.json.loads
        }

        try:
            # Use cgi.parse_header to correctly separate parameters from value
            value, parameters = cgi.parse_header(self.request.headers['Content-Type'])
            return ct_in_map[value](tornado.escape.native_str(data))
        except KeyError:
            self.send_error(406)
        except ValueError:
            self.send_error(400)
383367
function __deserializeData(type, buffer, start, options) {
	let result = {anchor:start, value:undefined};
	if (type === DATA_TYPE.NULL) {
		result = __deserializeNull(start, options);
	}
	else if (type === DATA_TYPE.FALSE || type === DATA_TYPE.TRUE) {
		result = __deserializeBoolean(type, start, options);
	}
	else if (type === DATA_TYPE.INT8) {
		result = __deserializeInt8(buffer, start, options);
	}
	else if (type === DATA_TYPE.INT16) {
		result = __deserializeInt16(buffer, start, options);
	}
	else if (type === DATA_TYPE.INT32) {
		result = __deserializeInt32(buffer, start, options);
	}
	else if (type === DATA_TYPE.INT64) {
		result = __deserializeInt64(buffer, start, options);
	}
	else if (type === DATA_TYPE.INT128) {
		result = __deserializeInt128(buffer, start, options);
	}
	else if (type === DATA_TYPE.INT256) {
		result = __deserializeInt256(buffer, start, options);
	}
	else if (type === DATA_TYPE.INT512) {
		result = __deserializeInt512(buffer, start, options);
	}
	else if (type === DATA_TYPE.INTVAR) {
		result = __deserializeIntVar(buffer, start, options);
	}
	else if (type === DATA_TYPE.UINT8) {
		result = __deserializeUInt8(buffer, start, options);
	}
	else if (type === DATA_TYPE.UINT16) {
		result = __deserializeUInt16(buffer, start, options);
	}
	else if (type === DATA_TYPE.UINT32) {
		result = __deserializeUInt32(buffer, start, options);
	}
	else if (type === DATA_TYPE.UINT64) {
		result = __deserializeUInt64(buffer, start, options);
	}
	else if (type === DATA_TYPE.UINT128) {
		result = __deserializeUInt128(buffer, start, options);
	}
	else if (type === DATA_TYPE.UINT256) {
		result = __deserializeUInt256(buffer, start, options);
	}
	else if (type === DATA_TYPE.UINT512) {
		result = __deserializeUInt512(buffer, start, options);
	}
	else if (type === DATA_TYPE.UINTVAR) {
		result = __deserializeUIntVar(buffer, start, options);
	}
	else if (type === DATA_TYPE.FLOAT32) {
		result = __deserializeFloat32(buffer, start, options);
	}
	else if (type === DATA_TYPE.FLOAT64) {
		result = __deserializeFloat64(buffer, start, options);
	}
	else if (type === DATA_TYPE.STRING) {
		result = __deserializeString(buffer, start, options);
	}
	else if (type === DATA_TYPE.ARRAY) {
		result = __deserializeArray(buffer, start, options);
	}
	else if (type === DATA_TYPE.ARRAY_START) {
		result = __deserializeArrayStreaming(buffer, start, options);
	}
	else if (type === DATA_TYPE.OBJECT) {
		result = __deserializeObject(buffer, start, options);
	}
	else if (type === DATA_TYPE.OBJECT_START) {
		result = __deserializeObjectStreaming(buffer, start, options);
	}
	else if (type === DATA_TYPE.DATE) {
		result = __deserializeDate(buffer, start, options);
	}
	else if (type === DATA_TYPE.OBJECTID) {
		result = __deserializeObjectId(buffer, start, options);
	}
	else if (type === DATA_TYPE.BINARY) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = Binary.FromArrayBuffer(result.value);
	}
	else if (type === DATA_TYPE.ARRAY_BUFFER) {
		result = __deserializeArrayBuffer(buffer, start, options);
	}
	else if (type === DATA_TYPE.DATA_VIEW) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = new DataView(result.value);
	}
	else if (type === DATA_TYPE.UINT8_ARRAY) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = new Uint8Array(result.value);
	}
	else if (type === DATA_TYPE.INT8_ARRAY) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = new Int8Array(result.value);
	}
	else if (type === DATA_TYPE.UINT16_ARRAY) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = new Uint16Array(result.value);
	}
	else if (type === DATA_TYPE.INT16_ARRAY) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = new Int16Array(result.value);
	}
	else if (type === DATA_TYPE.UINT32_ARRAY) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = new Uint32Array(result.value);
	}
	else if (type === DATA_TYPE.INT32_ARRAY) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = new Int32Array(result.value);
	}
	else if (type === DATA_TYPE.FLOAT32_ARRAY) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = new Float32Array(result.value);
	}
	else if (type === DATA_TYPE.FLOAT64_ARRAY) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = new Float64Array(result.value);
	}
	else if (type === DATA_TYPE.SPECIAL_BUFFER) {
		result = __deserializeArrayBuffer(buffer, start, options);
		result.value = HAS_NODE_BUFFER ? Buffer.from(result.value) : new Uint8Array(result.value);
	}
	
	return result;
}
1249422
function deserializeDHInnerData(context) {
    var decryptedDHParamsWithHash = context.decryptedDHParams;
    if (logger.isDebugEnabled()) {
        logger.debug('decryptedDHParamsWithHash(%s) = %s', decryptedDHParamsWithHash.length, decryptedDHParamsWithHash.toString('hex'));
    }
    var decryptedDHParams = decryptedDHParamsWithHash.slice(20, 564 + 20);
    if (logger.isDebugEnabled()) {
        logger.debug('decryptedDHParams(%s) = %s', decryptedDHParams.length, decryptedDHParams.toString('hex'));
    }
    var serverDHInnerData = new mtproto.type.Server_DH_inner_data({
        buffer: decryptedDHParams
    }).deserialize();
    if (logger.isDebugEnabled()) {
        logger.debug('serverDHInnerData = %s obtained in %sms', serverDHInnerData.toPrintable(), context.reqDHDuration);
    }
    // Check if the nonces are consistent
    if (serverDHInnerData.nonce !== context.serverDHParams.nonce) {
        throw createError('Nonce mismatch %s != %s', context.serverDHParams.nonce, serverDHInnerData.nonce);
    }
    if (serverDHInnerData.server_nonce !== context.serverDHParams.server_nonce) {
        throw createError('ServerNonce mismatch %s != %s', context.serverDHParams.server_nonce, serverDHInnerData.server_nonce);
    }
    // Synch the local time with the server time
    mtproto.time.timeSynchronization(serverDHInnerData.server_time, context.reqDHDuration);
    context.serverDHInnerData = serverDHInnerData;
    return context;
}
659189
@Override
    public <T> T body(Class<T> classOfT, Type genericType) {
        String rawContentType = request().contentType();

        // If the Content-type: xxx header is not set we return null.
        // we cannot parse that request.
        if (rawContentType == null) {
            return null;
        }

        // If Content-type is application/json; charset=utf-8 we split away the charset
        // application/json
        String contentTypeOnly = HttpUtils.getContentTypeFromContentTypeAndCharacterSetting(
                rawContentType);

        BodyParser parser = services.getContentEngines().getBodyParserEngineForContentType(contentTypeOnly);

        if (parser == null) {
            return null;
        }

        return parser.invoke(this, classOfT, genericType);
    }
660509
def _deserialize(self, value, attr, data, **kwargs):
        """"""
        if not value:  # falsy values are invalid
            self.fail('invalid')
        try:
            return utils.from_iso_time(value)
        except (AttributeError, TypeError, ValueError):
            self.fail('invalid')
595676
def parse_headers(self, req: Request, name: str, field: Field) -> typing.Any:
        """"""
        return core.get_value(req.headers, name, field)
812012
def deserialize(response, return_type)
      body = response.body

      # handle file downloading - return the File instance processed in request callbacks
      # note that response body is empty when the file is written in chunks in request on_body callback
      return @tempfile if return_type == 'File'

      return nil if body.nil? || body.empty?

      # return response body directly for String return type
      return body if return_type == 'String'

      # ensuring a default content type
      content_type = response.headers['Content-Type'] || 'application/json'

      raise "Content-Type is not supported: #{content_type}" unless json_mime?(content_type)

      begin
        data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
      rescue JSON::ParserError => e
        if %w[String Date DateTime].include?(return_type)
          data = body
        else
          raise e
        end
      end

      convert_to_type data, return_type
    end
676965
function __deserializeArrayStreaming(buffer, start, options) {
	let end = start;
	let dataView = new DataView(buffer);
	let endData = new Uint16Array(TYPE_HEADER.ARRAY_END);
	let data = [];
	while (start < buffer.byteLength) {
		let tmpType = dataView.getUint16(start, true);
		if (tmpType === endData[0]) {
			end += 2;
			break;
		}
		
		let subType, subData;
		({ anchor: start, value: subType } = __deserializeType(buffer, start, options));
		({ anchor: start, value: subData } = __deserializeData(subType, buffer, start, options));
		data.push(subData);
		end = start;
	}
	return { anchor: end, value: data };
}
973862
def deserialize(stream_or_string, **options):
    '''
    
    '''

    try:
        if not isinstance(stream_or_string, (bytes, six.string_types)):
            return toml.load(stream_or_string, **options)

        if isinstance(stream_or_string, bytes):
            stream_or_string = stream_or_string.decode('utf-8')

        return toml.loads(stream_or_string)
    except Exception as error:
        raise DeserializationError(error)
1187526
def serialize(self, data):
        '''
        
        '''
        self.set_header('Content-Type', self.content_type)

        return self.dumper(data)
797320
private static String getResponseMimeType(final HttpResponse httpHeadResponse) {
        Header contentTypeHeader = httpHeadResponse.getFirstHeader("Content-Type");
        if (contentTypeHeader != null) {
            String contentType = contentTypeHeader.getValue();
            if (contentType != null) {
                try {
                    return ContentType.parse(contentType).getMimeType();
                } catch (ParseException | UnsupportedCharsetException exception) {
                    return contentType.split(";")[0].trim();
                }
            }
        }

        return ContentType.DEFAULT_TEXT.getMimeType();
    }
874453
private void checkSerialize(final HttpServletRequest request) {
    String reqpar = request.getParameter("serialize");

    if (reqpar == null) {
      return;
    }

    HttpSession sess = request.getSession(false);
    Enumeration en = sess.getAttributeNames();

    while (en.hasMoreElements()) {
      String attrname = (String)en.nextElement();
      ObjectOutputStream oo = null;

      info("Attempt to serialize attr " + attrname);
      Object o = sess.getAttribute(attrname);

      try {
        ByteArrayOutputStream bo = new ByteArrayOutputStream();
        oo = new ObjectOutputStream(bo);
        oo.writeObject(o);
        oo.flush();

        info("Serialized object " + attrname + " has size: " + bo.size());
      } catch (Throwable t) {
        t.printStackTrace();
      } finally {
        if (oo != null) {
          try {
            oo.close();
          } catch (Throwable t) {}
        }
      }
    }
  }
894562
function __deserializeObjectStreaming(buffer, start, options) {
	let end = start;
	let dataView = new DataView(buffer);
	let endData = new Uint16Array(TYPE_HEADER.OBJECT_END);
	let data = {};
	while (start < buffer.byteLength) {
		let tmpType = dataView.getUint16(start, true);
		if (tmpType === endData[0]) {
			end += 2;
			break;
		}

		let subType, subKey, subData;
		({ anchor: start, value: subType } = __deserializeType(buffer, start, options));
		({ anchor: start, value: subKey } = __deserializeShortString(buffer, start, options));
		({ anchor: start, value: subData } = __deserializeData(subType, buffer, start, options));
		data[subKey] = subData;
		end = start;
	}
	return { anchor: end, value: data };
}
137773
def parse_headers(self, req, name, field):
        """"""
        return get_value(req.headers, name, field)
655902
def _parse_content_type_header(header):
    

    tokens = header.split(';')
    content_type, params = tokens[0].strip(), tokens[1:]
    params_dict = {}
    items_to_strip = "\"' "

    for param in params:
        param = param.strip()
        if param:
            key, value = param, True
            index_of_equals = param.find("=")
            if index_of_equals != -1:
                key = param[:index_of_equals].strip(items_to_strip)
                value = param[index_of_equals + 1:].strip(items_to_strip)
            params_dict[key.lower()] = value
    return content_type, params_dict
1136040
@SuppressWarnings("unchecked")
    @Override
    public final <T> T deserialize(byte[] content, Type type) throws SerializerException {
        if (byte[].class.equals(type)) {
            return (T) content;
        }
        throw new SerializerException("Unable to deserialize to type '" + type + "'");
    }
272780
def _deserialize(self, value, attr, data):
        """"""
        value = super(SanitizedHTML, self)._deserialize(value, attr, data)
        return bleach.clean(
            value,
            tags=self.tags,
            attributes=self.attrs,
            strip=True,
        ).strip()