protected void HandleOperationResponseHeaders(HttpStatusCode statusCode, Dictionary <string, string> headers) { Descriptor descriptor = this.ChangedEntries[this.entryIndex]; if (descriptor.DescriptorKind == DescriptorKind.Entity) { EntityDescriptor descriptor2 = (EntityDescriptor)descriptor; if ((((descriptor.State == EntityStates.Added) || (this.streamRequestKind == StreamRequestKind.PostMediaResource)) || Util.IsFlagSet(this.Options, SaveChangesOptions.PatchOnUpdate)) && WebUtil.SuccessStatusCode(statusCode)) { string str; string str2; Uri editLink = null; headers.TryGetValue("Location", out str); headers.TryGetValue("DataServiceId", out str2); if (str != null) { editLink = WebUtil.ValidateLocationHeader(str); } else if ((descriptor.State == EntityStates.Added) || (this.streamRequestKind == StreamRequestKind.PostMediaResource)) { throw System.Data.Services.Client.Error.NotSupported(System.Data.Services.Client.Strings.Deserialize_NoLocationHeader); } if (str2 != null) { if (str == null) { throw System.Data.Services.Client.Error.NotSupported(System.Data.Services.Client.Strings.Context_BothLocationAndIdMustBeSpecified); } WebUtil.ValidateIdentityValue(str2); } else { str2 = str; } if (null != editLink) { this.RequestInfo.EntityTracker.AttachLocation(descriptor2.Entity, str2, editLink); } } if (this.streamRequestKind != StreamRequestKind.None) { if (!WebUtil.SuccessStatusCode(statusCode)) { if (this.streamRequestKind == StreamRequestKind.PostMediaResource) { descriptor.State = EntityStates.Added; } this.streamRequestKind = StreamRequestKind.None; descriptor.ContentGeneratedForSave = true; } else { string str3; if ((this.streamRequestKind == StreamRequestKind.PostMediaResource) && headers.TryGetValue("ETag", out str3)) { descriptor2.ETag = str3; } } } } }