/// <summary> /// Check and updates the response version for POST MR operation. /// </summary> /// <param name="resourceType">Resource type for the MLE.</param> /// <param name="dataService">Data service instance.</param> internal void UpdateResponseVersionForPostMediaResource(ResourceType resourceType, IDataService dataService) { Debug.Assert(dataService != null && dataService.OperationContext.RequestMessage.HttpVerb == HttpVerbs.POST, "dataService != null && dataService.OperationContext.RequestMessage.AstoriaHttpVerb == AstoriaVerbs.POST"); Debug.Assert(this.LastSegmentInfo != null, "LastSegmentInfo != null"); Debug.Assert(this.LastSegmentInfo.TargetResourceSet != null, "LastSegmentInfo.TargetResourceSet != null"); // Raise response version due to features use by the response payload // This should only happen if we are going to write a payload in the response. For POST this is done by default // unless the Prefer header is set to NoContent. if (!this.Preference.ShouldNotIncludeResponseBody) { this.InitializeVersion(dataService); // we are getting the MinimumPayloadVersion from the type because we know the specific type so we // can get a more specific version this way ResourceSetWrapper resourceSet = this.LastSegmentInfo.TargetResourceSet; Version minimumPayloadVersion = resourceType.GetMinimumResponseVersion(dataService, resourceSet); this.VerifyAndRaiseResponseVersion(minimumPayloadVersion, dataService); } else { Debug.Assert( this.ResponseVersion >= VersionUtil.Version4Dot0, "If the return-no-content Prefer header is applied, the response version must be at least 4.0."); } }
/// <summary> /// Bump the minimum DSV requirement based on the specifics of the given resource type. /// </summary> /// <param name="resourceType">Resource type to inspect</param> /// <param name="topLevel">True if resourceType is the type for the top level element in the payload.</param> protected void UpdateAndCheckRequestResponseDSV(ResourceType resourceType, bool topLevel) { Debug.Assert(this.Service != null, "this.Service != null"); Debug.Assert(this.Service.Provider != null, "this.Service.Provider != null"); Debug.Assert(resourceType != null, "Must have valid resource type"); Debug.Assert(resourceType.ResourceTypeKind == ResourceTypeKind.EntityType, "resourceType.ResourceTypeKind == ResourceTypeKind.EntityType"); Debug.Assert(this.RequestDescription != null, "this.RequestDescription != null"); Debug.Assert(this.RequestDescription.LastSegmentInfo != null, "this.RequestDescription.LastSegmentInfo != null"); Debug.Assert(this.RequestDescription.LastSegmentInfo.TargetResourceSet != null, "this.RequestDescription.LastSegmentInfo.TargetContainer != null"); // Raise the response version if a response will be sent. if (topLevel && this.ResponseWillBeSent) { // We only raise the response version here but not minimum request version. // Because named stream links are not allowed on the request payload // and we allow collection properties in the request payload regardless of the request DSV since // we can easily recognize them (either having m:type="Collection()", or being declared in our metadata as collection) // and thus there's no chance to misinterpret the payload. // // we are getting the MinimumPayloadVersion from the type because we know the specific type so we // can get a more specific version this way ResourceSetWrapper resourceSet = this.RequestDescription.LastSegmentInfo.TargetResourceSet; Version minimumPayloadVersion = resourceType.GetMinimumResponseVersion(this.Service, resourceSet); if (!this.IsAtomRequest) { minimumPayloadVersion = resourceType.GetMinimumResponseVersion(this.Service, resourceSet); } this.RequestDescription.VerifyAndRaiseResponseVersion(minimumPayloadVersion, this.Service); } }