private ODataBatchOperationHeaders ValidatePartHeaders(ODataBatchOperationHeaders headers, out bool isChangeSetPart)
        {
            string str;

            if (!headers.TryGetValue("Content-Type", out str))
            {
                throw new ODataException(Strings.ODataBatchReaderStream_MissingContentTypeHeader);
            }
            if (MediaTypeUtils.MediaTypeAndSubtypeAreEqual(str, "application/http"))
            {
                string str2;
                isChangeSetPart = false;
                if (!headers.TryGetValue("Content-Transfer-Encoding", out str2) || (string.Compare(str2, "binary", StringComparison.OrdinalIgnoreCase) != 0))
                {
                    throw new ODataException(Strings.ODataBatchReaderStream_MissingOrInvalidContentEncodingHeader("Content-Transfer-Encoding", "binary"));
                }
                return(headers);
            }
            if (!MediaTypeUtils.MediaTypeStartsWithTypeAndSubtype(str, "multipart/mixed"))
            {
                throw new ODataException(Strings.ODataBatchReaderStream_InvalidContentTypeSpecified("Content-Type", str, "multipart/mixed", "application/http"));
            }
            isChangeSetPart = true;
            if (this.changesetBoundary != null)
            {
                throw new ODataException(Strings.ODataBatchReaderStream_NestedChangesetsAreNotSupported);
            }
            return(headers);
        }
        /// <summary>
        /// Validates the headers that have been read for a part.
        /// </summary>
        /// <param name="headers">The set of headers to validate.</param>
        /// <param name="isChangeSetPart">true if the headers indicate a changset part; otherwise false.</param>
        /// <returns>The set of validated headers.</returns>
        /// <remarks>
        /// An operation part is required to have content type 'application/http' and content transfer
        /// encoding 'binary'. A changeset is required to have content type 'multipart/mixed'.
        /// Note that we allow additional headers for batch parts; clients of the library can choose
        /// to be more strict.
        /// </remarks>
        private ODataBatchOperationHeaders ValidatePartHeaders(ODataBatchOperationHeaders headers, out bool isChangeSetPart)
        {
            string contentType;

            if (!headers.TryGetValue(ODataConstants.ContentTypeHeader, out contentType))
            {
                throw new ODataException(Strings.ODataBatchReaderStream_MissingContentTypeHeader);
            }

            if (MediaTypeUtils.MediaTypeAndSubtypeAreEqual(contentType, MimeConstants.MimeApplicationHttp))
            {
                isChangeSetPart = false;

                // An operation part is required to have application/http content type and
                // binary content transfer encoding.
                string transferEncoding;
                if (!headers.TryGetValue(ODataConstants.ContentTransferEncoding, out transferEncoding) ||
                    string.Compare(transferEncoding, ODataConstants.BatchContentTransferEncoding, StringComparison.OrdinalIgnoreCase) != 0)
                {
                    throw new ODataException(Strings.ODataBatchReaderStream_MissingOrInvalidContentEncodingHeader(
                                                 ODataConstants.ContentTransferEncoding,
                                                 ODataConstants.BatchContentTransferEncoding));
                }
            }
            else if (MediaTypeUtils.MediaTypeStartsWithTypeAndSubtype(contentType, MimeConstants.MimeMultipartMixed))
            {
                isChangeSetPart = true;

                if (this.changesetBoundary != null)
                {
                    // Nested changesets are not supported
                    throw new ODataException(Strings.ODataBatchReaderStream_NestedChangesetsAreNotSupported);
                }
            }
            else
            {
                throw new ODataException(Strings.ODataBatchReaderStream_InvalidContentTypeSpecified(
                                             ODataConstants.ContentTypeHeader,
                                             contentType,
                                             MimeConstants.MimeMultipartMixed,
                                             MimeConstants.MimeApplicationHttp));
            }

            return(headers);
        }