Exemple #1
0
        protected ODataMessageWriterSettingsBase(ODataMessageWriterSettingsBase other)
        {
            ExceptionUtils.CheckArgumentNotNull(other, "other");

            this.checkCharacters = other.checkCharacters;
            this.indent          = other.indent;
            this.messageQuotas   = new ODataMessageQuotas(other.MessageQuotas);
        }
        protected ODataMessageWriterSettingsBase(ODataMessageWriterSettingsBase other)
        {
            ExceptionUtils.CheckArgumentNotNull(other, "other");

            this.checkCharacters = other.checkCharacters;
            this.indent = other.indent;
            this.messageQuotas = new ODataMessageQuotas(other.MessageQuotas);
        }
        protected ODataMessageReaderSettingsBase(ODataMessageReaderSettingsBase other)
        {
            ExceptionUtils.CheckArgumentNotNull(other, "other");

            this.checkCharacters           = other.checkCharacters;
            this.enableAtomMetadataReading = other.enableAtomMetadataReading;
            this.messageQuotas             = new ODataMessageQuotas(other.MessageQuotas);
            this.shouldIncludeAnnotation   = other.shouldIncludeAnnotation;
        }
        protected ODataMessageReaderSettingsBase(ODataMessageReaderSettingsBase other)
        {
            ExceptionUtils.CheckArgumentNotNull(other, "other");

            this.checkCharacters = other.checkCharacters;
            this.enableAtomMetadataReading = other.enableAtomMetadataReading;
            this.messageQuotas = new ODataMessageQuotas(other.MessageQuotas);
            this.shouldIncludeAnnotation = other.shouldIncludeAnnotation;
        }
        internal static Task<HttpResponseMessage> CreateODataBatchResponseAsync(this HttpRequestMessage request, IEnumerable<ODataBatchResponseItem> responses, ODataMessageQuotas messageQuotas)
        {
            Contract.Assert(request != null);

            ODataVersion odataVersion = ODataMediaTypeFormatter.GetODataResponseVersion(request);
            ODataMessageWriterSettings writerSettings = new ODataMessageWriterSettings()
            {
                Version = odataVersion,
                Indent = true,
                DisableMessageStreamDisposal = true,
                MessageQuotas = messageQuotas
            };

            HttpResponseMessage response = request.CreateResponse(HttpStatusCode.OK);
            response.Content = new ODataBatchContent(responses, writerSettings);
            return Task.FromResult(response);
        }
        public void CopyConstructorShouldCopyMessageQuotas()
        {
            var originalQuotas = new ODataMessageQuotas()
            {
                MaxNestingDepth = 2,
                MaxOperationsPerChangeset = 3,
                MaxPartsPerBatch = 4,
                MaxReceivedMessageSize = 5
            };

            this.settings.MessageQuotas = originalQuotas;

            var copiedQuotas = (new ODataMessageWriterSettings(this.settings)).MessageQuotas;

            copiedQuotas.MaxNestingDepth.Should().Be(originalQuotas.MaxNestingDepth);
            copiedQuotas.MaxOperationsPerChangeset.Should().Be(originalQuotas.MaxOperationsPerChangeset);
            copiedQuotas.MaxPartsPerBatch.Should().Be(originalQuotas.MaxPartsPerBatch);
            copiedQuotas.MaxReceivedMessageSize.Should().Be(originalQuotas.MaxReceivedMessageSize);
        }
        public void CreateODataBatchResponseAsync_ReturnsHttpStatusCodeOK()
        {
            // Arrange
            HttpRequestMessage request = new HttpRequestMessage();
            var responses = new ODataBatchResponseItem[] { };
            var quotas = new ODataMessageQuotas();

            // Act
            var response = request.CreateODataBatchResponseAsync(responses, quotas).Result;

            // Assert
            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        }
Exemple #8
0
 /// <summary>
 /// Set the message quota limits for WCF Data services server.
 /// </summary>
 /// <param name="messageQuotas">Instance of ODataMessageQuotas.</param>
 internal static void SetDefaultMessageQuotas(ODataMessageQuotas messageQuotas)
 {
     // NOTE: the size of the input message is only limited by the WCF message size in Astoria
     // In WCF DS client, we never had a limit on any of these. Hence for client, it makes sense
     // to set these values to some high limit. In WCF DS server, there are bunch of API's to 
     // cover some of these limits and if we pass the value to ODL, for batch requests, there is
     // a breaking change, since WCF DS server cannot figure out why the exception was thrown and
     // and hence fail way early. For now, the best way is to tell ODL to not impose any limits
     // and WCF DS server imposes the limits in its own way.
     messageQuotas.MaxReceivedMessageSize = long.MaxValue;
     messageQuotas.MaxPartsPerBatch = int.MaxValue;
     messageQuotas.MaxOperationsPerChangeset = int.MaxValue;
     messageQuotas.MaxNestingDepth = int.MaxValue;
 }