/// <summary>
        /// Reads the headers of a part.
        /// </summary>
        /// <returns>true if the start of a changeset part was detected; otherwise false.</returns>
        internal bool ProcessPartHeader()
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(this.batchEncoding != null, "Batch encoding should have been established on first call to SkipToBoundary.");

            bool isChangeSetPart;
            ODataBatchOperationHeaders headers = this.ReadPartHeaders(out isChangeSetPart);

            if (isChangeSetPart)
            {
                // determine the changeset boundary and the changeset encoding from the content type header
                this.DetermineChangesetBoundaryAndEncoding(headers[ODataConstants.ContentTypeHeader]);

                if (this.changesetEncoding == null)
                {
                    // NOTE: No changeset encoding was specified in the changeset's content type header.
                    //       Determine the changeset encoding from the first bytes in the changeset.
                    // NOTE: We do not have to skip over the potential preamble of the encoding
                    //       because the batch reader will skip over everything (incl. the preamble)
                    //       until it finds the first changeset (or batch) boundary
                    this.changesetEncoding = this.DetectEncoding();
                }

                // Verify that we only allow single byte encodings and UTF-8 for now.
                ReaderValidationUtils.ValidateEncodingSupportedInBatch(this.changesetEncoding);
            }

            return(isChangeSetPart);
        }
Пример #2
0
 private void EnsureBatchEncoding()
 {
     if (this.batchEncoding == null)
     {
         this.batchEncoding = this.DetectEncoding();
     }
     ReaderValidationUtils.ValidateEncodingSupportedInBatch(this.batchEncoding);
 }
        /// <summary>
        /// Ensure that a batch encoding exists; if not, detect it from the first couple of bytes of the stream.
        /// </summary>
        private void EnsureBatchEncoding()
        {
            // If no batch encoding is specified we detect it from the first bytes in the buffer.
            if (this.batchEncoding == null)
            {
                // NOTE: The batch encoding will only ever be null on the first call to this method which
                //       happens before the batch reader skips to the first boundary.
                this.batchEncoding = this.DetectEncoding();
            }

            // Verify that we only allow single byte encodings and UTF-8 for now.
            ReaderValidationUtils.ValidateEncodingSupportedInBatch(this.batchEncoding);
        }
Пример #4
0
        internal bool ProcessPartHeader()
        {
            bool flag;
            ODataBatchOperationHeaders headers = this.ReadPartHeaders(out flag);

            if (flag)
            {
                this.DetermineChangesetBoundaryAndEncoding(headers["Content-Type"]);
                if (this.changesetEncoding == null)
                {
                    this.changesetEncoding = this.DetectEncoding();
                }
                ReaderValidationUtils.ValidateEncodingSupportedInBatch(this.changesetEncoding);
            }
            return(flag);
        }