Exemple #1
0
        internal EffectiveValueEntry GetFlattenedEntry(RequestFlags requests)
        {
            if ((_source & (FullValueSource.ModifiersMask | FullValueSource.HasExpressionMarker)) == 0)
            {
                // If the property does not have any modifiers
                // then just return the base value.
                return this;
            }

            if (!HasModifiers)
            {
                Debug.Assert(HasExpressionMarker);

                // This is the case when some one stuck an expression into
                // an alternate store such as a style or a template but the
                // new value for the expression has not been evaluated yet.
                // In the intermediate we need to return the default value
                // for the property. This problem was manifested in DRTDocumentViewer.
                EffectiveValueEntry unsetEntry = new EffectiveValueEntry();
                unsetEntry.BaseValueSourceInternal = BaseValueSourceInternal;
                unsetEntry.PropertyIndex = PropertyIndex;
                return unsetEntry;
            }

            // else entry has modifiers
            EffectiveValueEntry entry = new EffectiveValueEntry();
            entry.BaseValueSourceInternal = BaseValueSourceInternal;
            entry.PropertyIndex = PropertyIndex;
            entry.IsDeferredReference = IsDeferredReference;

            // If the property has a modifier return the modified value
            Debug.Assert(ModifiedValue != null);

            // outside of DO, we flatten modified value
            ModifiedValue modifiedValue = ModifiedValue;

            // Note that the modified values have an order of precedence
            // 1. Coerced Value (including Current value)
            // 2. Animated Value
            // 3. Expression Value
            // Also note that we support any arbitrary combinations of these
            // modifiers and will yet the precedence metioned above.
            if (IsCoerced)
            {
                if ((requests & RequestFlags.CoercionBaseValue) == 0)
                {
                    entry.Value = modifiedValue.CoercedValue;
                }
                else
                {
                    // This is the case when CoerceValue tries to query
                    // the old base value for the property
                    if (IsCoercedWithCurrentValue)
                    {
                        entry.Value = modifiedValue.CoercedValue;
                    }
                    else if (IsAnimated && ((requests & RequestFlags.AnimationBaseValue) == 0))
                    {
                        entry.Value = modifiedValue.AnimatedValue;
                    }
                    else if (IsExpression)
                    {
                        entry.Value = modifiedValue.ExpressionValue;
                    }
                    else
                    {
                        entry.Value = modifiedValue.BaseValue;
                    }
                }
            }
            else if (IsAnimated)
            {
                if ((requests & RequestFlags.AnimationBaseValue) == 0)
                {
                    entry.Value = modifiedValue.AnimatedValue;
                }
                else
                {
                    // This is the case when [UI/Content]Element are
                    // requesting the base value of an animation.
                    if (IsExpression)
                    {
                        entry.Value = modifiedValue.ExpressionValue;
                    }
                    else
                    {
                        entry.Value = modifiedValue.BaseValue;
                     }
                }
            }
            else
            {
                Debug.Assert(IsExpression == true);

                object expressionValue = modifiedValue.ExpressionValue;

                entry.Value = expressionValue;
            }

            Debug.Assert(entry.IsDeferredReference == (entry.Value is DeferredReference), "Value and DeferredReference flag should be in [....]; hitting this may mean that it's time to divide the DeferredReference flag into a set of flags, one for each modifier");

            return entry;
        }
		protected internal override async Task<HttpResponse> HandleRequest (
			TestContext ctx, HttpOperation operation, HttpConnection connection, HttpRequest request,
			RequestFlags effectiveFlags, CancellationToken cancellationToken)
		{
			switch (TestRunner.EffectiveType) {
			case HttpRequestTestType.LargeHeader:
			case HttpRequestTestType.LargeHeader2:
			case HttpRequestTestType.SendResponseAsBlob:
			case HttpRequestTestType.CloseRequestStream:
			case HttpRequestTestType.ReadTimeout:
			case HttpRequestTestType.SimpleGZip:
			case HttpRequestTestType.TestResponseStream:
			case HttpRequestTestType.LargeChunkRead:
			case HttpRequestTestType.LargeGZipRead:
			case HttpRequestTestType.GZipWithLength:
			case HttpRequestTestType.ResponseStreamCheckLength2:
			case HttpRequestTestType.ResponseStreamCheckLength:
			case HttpRequestTestType.GetNoLength:
				ctx.Assert (request.Method, Is.EqualTo ("GET"), "method");
				break;

			case HttpRequestTestType.ServerAbortsPost:
				ctx.Assert (request.Method, Is.EqualTo ("POST"), "method");
				break;

			case HttpRequestTestType.RedirectNoLength:
			case HttpRequestTestType.PutChunked:
			case HttpRequestTestType.PutChunkDontCloseRequest:
			case HttpRequestTestType.ServerAbortsRedirect:
				break;

			case HttpRequestTestType.EntityTooBig:
				await EntityTooBig ().ConfigureAwait (false);
				return null;

			case HttpRequestTestType.PostChunked:
				return await HandlePostChunked (
					ctx, operation, connection, request, effectiveFlags, cancellationToken).ConfigureAwait (false);

			case HttpRequestTestType.PostContentLength:
				await PostContentLength ().ConfigureAwait (false);
				break;

			case HttpRequestTestType.ClientAbortsPost:
				await ClientAbortsPost ().ConfigureAwait (false);
				return null;

			case HttpRequestTestType.ImplicitHost:
				var hostAndPort = TestRunner.Uri.GetComponents (UriComponents.HostAndPort, UriFormat.Unescaped);
				ctx.Assert (request.Headers["Host"], Is.EqualTo (hostAndPort), "host");
				break;

			case HttpRequestTestType.CustomHost:
				ctx.Assert (request.Headers["Host"], Is.EqualTo ("custom"), "host");
				break;

			case HttpRequestTestType.CustomHostWithPort:
				ctx.Assert (request.Headers["Host"], Is.EqualTo ("custom:8888"), "host");
				break;

			case HttpRequestTestType.CustomHostDefaultPort:
				var defaultPort = TestRunner.Server.UseSSL ? 443 : 80;
				ctx.Assert (request.Headers["Host"], Is.EqualTo ($"custom:{defaultPort}"), "host");
				break;

			default:
				throw ctx.AssertFail (TestRunner.EffectiveType);
			}

			RemoteEndPoint = connection.RemoteEndPoint;

			HttpResponse response;
			HttpRequestContent content;
			ListenerOperation redirect;

			switch (TestRunner.EffectiveType) {
			case HttpRequestTestType.LargeHeader:
				response = new HttpResponse (HttpStatusCode.OK, Content);
				response.AddHeader ("LargeTest", ConnectionHandler.GetLargeText (100));
				return response;

			case HttpRequestTestType.LargeHeader2:
				response = new HttpResponse (HttpStatusCode.OK, Content);
				response.AddHeader ("LargeTest", ConnectionHandler.GetLargeText (100));
				response.WriteAsBlob = true;
				return response;

			case HttpRequestTestType.SendResponseAsBlob:
				return new HttpResponse (HttpStatusCode.OK, Content) {
					WriteAsBlob = true
				};

			case HttpRequestTestType.ReadTimeout:
				content = new HttpRequestContent (TestRunner, currentRequest);
				return new HttpResponse (HttpStatusCode.OK, content);

			case HttpRequestTestType.RedirectNoLength:
				redirect = operation.RegisterRedirect (ctx, Target);
				response = HttpResponse.CreateRedirect (HttpStatusCode.Redirect, redirect);
				response.NoContentLength = true;
				return response;

			case HttpRequestTestType.ServerAbortsRedirect:
				if (isSecondRequest)
					throw ctx.AssertFail ("Should never happen.");
				var cloned = new HttpRequestHandler (this);
				cloned.isSecondRequest = true;
				redirect = operation.RegisterRedirect (ctx, cloned);
				response = HttpResponse.CreateRedirect (HttpStatusCode.Redirect, redirect);
				return response;

			case HttpRequestTestType.ServerAbortsPost:
				return new HttpResponse (HttpStatusCode.BadRequest, Content);

			case HttpRequestTestType.SimpleGZip:
				var gzipContent = new GZipContent (ConnectionHandler.TheQuickBrownFoxBuffer);
				return new HttpResponse (HttpStatusCode.OK, gzipContent);

			case HttpRequestTestType.TestResponseStream:
				response = new HttpResponse (HttpStatusCode.OK, Content);
				response.WriteAsBlob = true;
				return response;

			case HttpRequestTestType.LargeChunkRead:
				response = new HttpResponse (HttpStatusCode.OK, Content);
				response.WriteBodyAsBlob = true;
				return response;

			case HttpRequestTestType.LargeGZipRead:
				gzipContent = new GZipContent ((ChunkedContent)Content);
				response = new HttpResponse (HttpStatusCode.OK, gzipContent);
				return response;

			case HttpRequestTestType.GZipWithLength:
				gzipContent = new GZipContent ((StringContent)Content);
				response = new HttpResponse (HttpStatusCode.OK, gzipContent);
				return response;

			case HttpRequestTestType.ResponseStreamCheckLength2:
			case HttpRequestTestType.ResponseStreamCheckLength:
				response = new HttpResponse (HttpStatusCode.OK, Content);
				return response;

			case HttpRequestTestType.GetNoLength:
				content = new HttpRequestContent (TestRunner, currentRequest);
				return new HttpResponse (HttpStatusCode.OK, content);

			default:
				return HttpResponse.CreateSuccess (ME);
			}

			async Task EntityTooBig ()
			{
				await request.ReadHeaders (ctx, cancellationToken).ConfigureAwait (false);
				await ctx.AssertException<IOException> (() => request.Read (ctx, cancellationToken), "client doesn't send any body");
			}

			async Task ClientAbortsPost ()
			{
				await request.ReadHeaders (ctx, cancellationToken).ConfigureAwait (false);
				await ctx.AssertException<IOException> (() => request.Read (ctx, cancellationToken), "client doesn't send any body");
			}

			async Task PostContentLength ()
			{
				await request.ReadHeaders (ctx, cancellationToken).ConfigureAwait (false);
				ctx.Assert (request.ContentLength, Is.EqualTo (currentRequest.Content.Length), "request.ContentLength");
				readyTcs.TrySetResult (true);
				await request.Read (ctx, cancellationToken);
			}
		}
Exemple #3
0
 protected internal abstract Task <HttpResponse> HandleRequest(
     TestContext ctx, HttpOperation operation, HttpConnection connection,
     HttpRequest request, RequestFlags effectiveFlags,
     CancellationToken cancellationToken);
Exemple #4
0
 public static extern bool SQLConfigDataSource(IntPtr hwndParent, RequestFlags fRequest, string lpszDriver, string lpszAttributes);
        internal EffectiveValueEntry GetFlattenedEntry(RequestFlags requests)
        {
            if ((_source & (FullValueSource.ModifiersMask | FullValueSource.HasExpressionMarker)) == 0)
            {
                // If the property does not have any modifiers
                // then just return the base value.
                return(this);
            }

            if (!HasModifiers)
            {
                Debug.Assert(HasExpressionMarker);

                // This is the case when some one stuck an expression into
                // an alternate store such as a style or a template but the
                // new value for the expression has not been evaluated yet.
                // In the intermediate we need to return the default value
                // for the property. This problem was manifested in DRTDocumentViewer.
                EffectiveValueEntry unsetEntry = new EffectiveValueEntry();
                unsetEntry.BaseValueSourceInternal = BaseValueSourceInternal;
                unsetEntry.PropertyIndex           = PropertyIndex;
                return(unsetEntry);
            }

            // else entry has modifiers
            EffectiveValueEntry entry = new EffectiveValueEntry();

            entry.BaseValueSourceInternal = BaseValueSourceInternal;
            entry.PropertyIndex           = PropertyIndex;
            entry.IsDeferredReference     = IsDeferredReference;

            // If the property has a modifier return the modified value
            Debug.Assert(ModifiedValue != null);

            // outside of DO, we flatten modified value
            ModifiedValue modifiedValue = ModifiedValue;

            // Note that the modified values have an order of precedence
            // 1. Coerced Value (including Current value)
            // 2. Animated Value
            // 3. Expression Value
            // Also note that we support any arbitrary combinations of these
            // modifiers and will yet the precedence metioned above.
            if (IsCoerced)
            {
                if ((requests & RequestFlags.CoercionBaseValue) == 0)
                {
                    entry.Value = modifiedValue.CoercedValue;
                }
                else
                {
                    // This is the case when CoerceValue tries to query
                    // the old base value for the property
                    if (IsCoercedWithCurrentValue)
                    {
                        entry.Value = modifiedValue.CoercedValue;
                    }
                    else if (IsAnimated && ((requests & RequestFlags.AnimationBaseValue) == 0))
                    {
                        entry.Value = modifiedValue.AnimatedValue;
                    }
                    else if (IsExpression)
                    {
                        entry.Value = modifiedValue.ExpressionValue;
                    }
                    else
                    {
                        entry.Value = modifiedValue.BaseValue;
                    }
                }
            }
            else if (IsAnimated)
            {
                if ((requests & RequestFlags.AnimationBaseValue) == 0)
                {
                    entry.Value = modifiedValue.AnimatedValue;
                }
                else
                {
                    // This is the case when [UI/Content]Element are
                    // requesting the base value of an animation.
                    if (IsExpression)
                    {
                        entry.Value = modifiedValue.ExpressionValue;
                    }
                    else
                    {
                        entry.Value = modifiedValue.BaseValue;
                    }
                }
            }
            else
            {
                Debug.Assert(IsExpression == true);

                object expressionValue = modifiedValue.ExpressionValue;

                entry.Value = expressionValue;
            }

            Debug.Assert(entry.IsDeferredReference == (entry.Value is DeferredReference), "Value and DeferredReference flag should be in sync; hitting this may mean that it's time to divide the DeferredReference flag into a set of flags, one for each modifier");

            return(entry);
        }
        bool CheckTransferMode(Connection connection, RequestFlags effectiveFlags)
        {
            var haveContentLength = connection.Headers.ContainsKey ("Content-Length");
            var haveTransferEncoding = connection.Headers.ContainsKey ("Transfer-Encoding");

            if ((effectiveFlags & RequestFlags.RedirectedAsGet) != 0) {
                if (haveContentLength) {
                    WriteError (connection, "Content-Length header not allowed");
                    return false;
                }

                if (haveTransferEncoding) {
                    WriteError (connection, "Transfer-Encoding header not allowed");
                    return false;
                }

                return true;
            }

            switch (Mode) {
            case TransferMode.Default:
                if (Body != null) {
                    if (!haveContentLength) {
                        WriteError (connection, "Missing Content-Length");
                        return false;
                    }

                    return ReadStaticBody (connection);
                } else {
                    if (haveContentLength) {
                        WriteError (connection, "Content-Length header not allowed");
                        return false;
                    }

                    return true;
                }

            case TransferMode.ContentLength:
                if (!haveContentLength) {
                    WriteError (connection, "Missing Content-Length");
                    return false;
                }

                if (haveTransferEncoding) {
                    WriteError (connection, "Transfer-Encoding header not allowed");
                    return false;
                }

                return ReadStaticBody (connection);

            case TransferMode.Chunked:
                if (haveContentLength) {
                    WriteError (connection, "Content-Length header not allowed");
                    return false;
                }

                if (!haveTransferEncoding) {
                    WriteError (connection, "Missing Transfer-Encoding header");
                    return false;
                }

                var transferEncoding = connection.Headers ["Transfer-Encoding"];
                if (!string.Equals (transferEncoding, "chunked", StringComparison.InvariantCultureIgnoreCase)) {
                    WriteError (connection, "Invalid Transfer-Encoding header: '{0}'", transferEncoding);
                    return false;
                }

                var body = ReadChunkedBody (connection);
                Console.WriteLine ("CHUNKED BODY: |{0}|", body);

                return true;

            default:
                WriteError (connection, "Unknown TransferMode: '{0}'", Mode);
                return false;
            }
        }
        [FriendAccessAllowed] // Built into Base, also used by Core.
        internal EffectiveValueEntry GetValueEntry( 
            EntryIndex          entryIndex,
            DependencyProperty  dp,
            PropertyMetadata    metadata,
            RequestFlags        requests) 
        {
            EffectiveValueEntry entry; 
 
            if (dp.ReadOnly)
            { 
                if (metadata == null)
                {
                    metadata = dp.GetMetadata(DependencyObjectType);
                } 

                GetReadOnlyValueCallback getValueCallback = metadata.GetReadOnlyValueCallback; 
                if (getValueCallback != null) 
                {
                    BaseValueSourceInternal valueSource; 
                    entry = new EffectiveValueEntry(dp);
                    entry.Value = getValueCallback(this, out valueSource);
                    entry.BaseValueSourceInternal = valueSource;
                    return entry; 
                }
            } 
 
            if (entryIndex.Found)
            { 
                if ((requests & RequestFlags.RawEntry) != 0)
                {
                    entry = _effectiveValues[entryIndex.Index];
                } 
                else
                { 
                    entry = GetEffectiveValue( 
                                entryIndex,
                                dp, 
                                requests);
                }
            }
            else 
            {
                entry = new EffectiveValueEntry(dp, BaseValueSourceInternal.Unknown); 
            } 

            if (entry.Value == DependencyProperty.UnsetValue) 
            {
                if (dp.IsPotentiallyInherited)
                {
                    if (metadata == null) 
                    {
                        metadata = dp.GetMetadata(DependencyObjectType); 
                    } 

                    if (metadata.IsInherited) 
                    {
                        DependencyObject inheritanceParent = InheritanceParent;
                        if (inheritanceParent != null)
                        { 
                            entryIndex = inheritanceParent.LookupEntry(dp.GlobalIndex);
 
                            if (entryIndex.Found) 
                            {
                                entry = inheritanceParent.GetEffectiveValue( 
                                                entryIndex,
                                                dp,
                                                requests & RequestFlags.DeferredReferences);
                                entry.BaseValueSourceInternal = BaseValueSourceInternal.Inherited; 
                            }
                        } 
                    } 

                    if (entry.Value != DependencyProperty.UnsetValue) 
                    {
                        return entry;
                    }
                } 

                if ((requests & RequestFlags.SkipDefault) == 0) 
                { 
                    if (dp.IsPotentiallyUsingDefaultValueFactory)
                    { 
                        if (metadata == null)
                        {
                            metadata = dp.GetMetadata(DependencyObjectType);
                        } 

                        if (((requests & (RequestFlags.DeferredReferences | RequestFlags.RawEntry)) != 0) && metadata.UsingDefaultValueFactory) 
                        { 
                            entry.BaseValueSourceInternal = BaseValueSourceInternal.Default;
 
                            entry.Value = new DeferredMutableDefaultReference(metadata, this, dp);
                            return entry;
                        }
                    } 
                    else if (!dp.IsDefaultValueChanged)
                    { 
                        return EffectiveValueEntry.CreateDefaultValueEntry(dp, dp.DefaultMetadata.DefaultValue); 
                    }
 
                    if (metadata == null)
                    {
                        metadata = dp.GetMetadata(DependencyObjectType);
                    } 

                    return EffectiveValueEntry.CreateDefaultValueEntry(dp, metadata.GetDefaultValue(this, dp)); 
                } 
            }
            return entry; 
        }
        private static void CleanADOrphanAndInconsistencyForMoves(IRecipientSession recipientSession, RequestJobProvider rjProvider, Guid dbGuid)
        {
            ADObjectId  propertyValue = new ADObjectId(dbGuid);
            QueryFilter queryFilter   = new AndFilter(new QueryFilter[]
            {
                new ComparisonFilter(ComparisonOperator.NotEqual, ADUserSchema.MailboxMoveStatus, RequestStatus.None),
                new ExistsFilter(ADUserSchema.MailboxMoveStatus)
            });
            QueryFilter queryFilter2 = QueryFilter.OrTogether(new QueryFilter[]
            {
                QueryFilter.AndTogether(new QueryFilter[]
                {
                    new ComparisonFilter(ComparisonOperator.Equal, ADUserSchema.MailboxMoveSourceMDB, propertyValue),
                    new BitMaskAndFilter(ADUserSchema.MailboxMoveFlags, 4UL)
                }),
                QueryFilter.AndTogether(new QueryFilter[]
                {
                    new ComparisonFilter(ComparisonOperator.Equal, ADUserSchema.MailboxMoveTargetMDB, propertyValue),
                    new BitMaskAndFilter(ADUserSchema.MailboxMoveFlags, 8UL)
                })
            });
            QueryFilter filter = new AndFilter(new QueryFilter[]
            {
                queryFilter,
                queryFilter2
            });

            ADRecipient[] array = recipientSession.Find(null, QueryScope.SubTree, filter, null, 1000);
            if (array == null || array.Length == 0)
            {
                MrsTracer.Service.Debug("CleanADOrphanAndInconsistencyForMoves(): No move requests found for DB {0}", new object[]
                {
                    dbGuid
                });
                return;
            }
            bool needUpdateAD = false;

            ADRecipient[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                ADRecipient request = array2[i];
                CommonUtils.CatchKnownExceptions(delegate
                {
                    needUpdateAD  = false;
                    ADUser aduser = request as ADUser;
                    MoveRequestStatistics moveRequestStatistics = (MoveRequestStatistics)rjProvider.Read <MoveRequestStatistics>(new RequestJobObjectId(aduser.ExchangeGuid, dbGuid, null));
                    if (moveRequestStatistics == null || (!moveRequestStatistics.IsFake && moveRequestStatistics.Status == RequestStatus.None))
                    {
                        MrsTracer.Service.Debug("CleanADOrphanAndInconsistencyForMoves():AD orphan {0} found for DB {1}", new object[]
                        {
                            aduser.ExchangeGuid,
                            dbGuid
                        });
                        CommonUtils.CleanupMoveRequestInAD(recipientSession, null, aduser);
                        return;
                    }
                    if (moveRequestStatistics.IsFake)
                    {
                        MrsTracer.Service.Debug("CleanADOrphanAndInconsistencyForMoves():request {0} is uplevel/Fake, ignore it", new object[]
                        {
                            aduser.ExchangeGuid
                        });
                        return;
                    }
                    if (moveRequestStatistics.User == null)
                    {
                        MrsTracer.Service.Debug("CleanADOrphanAndInconsistencyForMoves():request {0} has been deleted from AD, ignore it", new object[]
                        {
                            aduser.ExchangeGuid
                        });
                        return;
                    }
                    if (moveRequestStatistics.TimeTracker.GetCurrentDurationChunk() > ADInconsistencyCheck.updateLatencyThreshhold)
                    {
                        RequestStatus versionAppropriateStatus = RequestJobBase.GetVersionAppropriateStatus(moveRequestStatistics.Status, aduser.ExchangeVersion);
                        if (versionAppropriateStatus != moveRequestStatistics.User.MailboxMoveStatus)
                        {
                            MrsTracer.Service.Debug("CleanADOrphanAndInconsistencyForMoves():AD inconsistency {0} found for DB {1}, AD status is {2} but store status is {3} ({4})", new object[]
                            {
                                aduser.ExchangeGuid,
                                dbGuid,
                                aduser.MailboxMoveStatus,
                                moveRequestStatistics.Status,
                                versionAppropriateStatus
                            });
                            aduser.MailboxMoveStatus = versionAppropriateStatus;
                            needUpdateAD             = true;
                        }
                        RequestFlags versionAppropriateFlags = RequestJobBase.GetVersionAppropriateFlags(moveRequestStatistics.Flags, aduser.ExchangeVersion);
                        if (versionAppropriateFlags != moveRequestStatistics.User.MailboxMoveFlags)
                        {
                            MrsTracer.Service.Debug("CleanADOrphanAndInconsistencyForMoves():AD inconsistency {0} found for DB {1}, AD flags is {2} but store flags is {3} ({4})", new object[]
                            {
                                aduser.ExchangeGuid,
                                dbGuid,
                                aduser.MailboxMoveFlags,
                                moveRequestStatistics.Flags,
                                versionAppropriateFlags
                            });
                            aduser.MailboxMoveFlags = versionAppropriateFlags;
                            needUpdateAD            = true;
                        }
                        if (needUpdateAD)
                        {
                            recipientSession.Save(request);
                        }
                    }
                }, delegate(Exception f)
                {
                    MrsTracer.Service.Error("CleanADOrphanAndInconsistencyForMoves() failed for DB {0}. move request {1} Error: {2}", new object[]
                    {
                        dbGuid,
                        ((ADUser)request).ExchangeGuid,
                        CommonUtils.FullExceptionMessage(f, true)
                    });
                    MRSService.LogEvent(MRSEventLogConstants.Tuple_ScanADInconsistencyRequestFailEvent, new object[]
                    {
                        dbGuid,
                        MRSRequestType.Move.ToString(),
                        ((ADUser)request).ExchangeGuid,
                        CommonUtils.FullExceptionMessage(f, true)
                    });
                });
            }
        }
Exemple #9
0
        protected internal override HttpResponse HandleRequest(HttpConnection connection, HttpRequest request, RequestFlags effectiveFlags)
        {
            if (!request.Method.Equals("DELETE"))
            {
                return(HttpResponse.CreateError("Wrong method: {0}", request.Method));
            }

            string value;
            var    hasLength         = request.Headers.TryGetValue("Content-Length", out value);
            var    hasExplicitLength = (Flags & RequestFlags.ExplicitlySetLength) != 0;

            if (hasLength)
            {
                var length = int.Parse(value);

                if (Body != null)
                {
                    request.ReadBody();
                    return(HttpResponse.CreateSuccess());
                }
                else if (hasExplicitLength)
                {
                    if (length != 0)
                    {
                        return(HttpResponse.CreateError("Content-Length must be zero"));
                    }
                }
                else
                {
                    return(HttpResponse.CreateError("Content-Length not allowed."));
                }
            }
            else if (hasExplicitLength || Body != null)
            {
                return(HttpResponse.CreateError("Missing Content-Length"));
            }

            return(HttpResponse.CreateSuccess());
        }
Exemple #10
0
        public static void ReserveLocalForestResources(ReservationContext reservation, WorkloadType workloadType, MRSRequestType requestType, RequestFlags requestFlags, Guid archiveGuid, Guid exchangeGuid, Guid sourceExchangeGuid, Guid targetExchangeGuid, TenantPartitionHint partitionHint, ADObjectId sourceDatabase, ADObjectId sourceArchiveDatabase, ADObjectId targetDatabase, ADObjectId targetArchiveDatabase, Guid sourceDatabaseGuid, Guid sourceArchiveDatabaseGuid, Guid targetDatabaseGuid, Guid targetArchiveDatabaseGuid)
        {
            ReservationFlags reservationFlags;
            Guid             guid;
            Guid             guid2;

            if (requestType == MRSRequestType.Move || requestType == MRSRequestType.MailboxRelocation)
            {
                reservationFlags = ReservationFlags.Move;
                if (requestFlags.HasFlag(RequestFlags.MoveOnlyArchiveMailbox) && archiveGuid != Guid.Empty)
                {
                    guid = archiveGuid;
                }
                else
                {
                    guid = exchangeGuid;
                }
                guid2 = guid;
            }
            else
            {
                reservationFlags = ReservationFlags.Merge;
                guid             = sourceExchangeGuid;
                guid2            = targetExchangeGuid;
            }
            if (workloadType != Microsoft.Exchange.WorkloadManagement.WorkloadType.MailboxReplicationServiceHighPriority)
            {
                switch (workloadType)
                {
                case Microsoft.Exchange.WorkloadManagement.WorkloadType.MailboxReplicationServiceInternalMaintenance:
                    reservationFlags |= ReservationFlags.InternalMaintenance;
                    break;

                case Microsoft.Exchange.WorkloadManagement.WorkloadType.MailboxReplicationServiceInteractive:
                    reservationFlags |= ReservationFlags.Interactive;
                    break;
                }
            }
            else
            {
                reservationFlags |= ReservationFlags.HighPriority;
            }
            reservation.ReserveResource((guid2 == Guid.Empty) ? guid : guid2, partitionHint, MRSResource.Id, reservationFlags);
            if (targetDatabaseGuid != Guid.Empty)
            {
                reservation.ReserveResource(guid2, partitionHint, targetDatabase, reservationFlags | ReservationFlags.Write);
            }
            if (targetArchiveDatabaseGuid != Guid.Empty && targetArchiveDatabaseGuid != targetDatabaseGuid && archiveGuid != Guid.Empty)
            {
                reservation.ReserveResource(archiveGuid, partitionHint, targetArchiveDatabase, reservationFlags | ReservationFlags.Write | ReservationFlags.Archive);
            }
            if (sourceDatabaseGuid != Guid.Empty)
            {
                reservation.ReserveResource(guid, partitionHint, sourceDatabase, reservationFlags | ReservationFlags.Read);
            }
            if (sourceArchiveDatabaseGuid != Guid.Empty && sourceArchiveDatabaseGuid != sourceDatabaseGuid && archiveGuid != Guid.Empty)
            {
                reservation.ReserveResource(archiveGuid, partitionHint, sourceArchiveDatabase, reservationFlags | ReservationFlags.Read | ReservationFlags.Archive);
            }
        }
Exemple #11
0
 public EverythingSearchOptions GetFields(RequestFlags requestedFields)
 {
     Flags = requestedFields;
     return(this);
 }
Exemple #12
0
        internal protected override async Task <HttpResponse> HandleRequest(
            TestContext ctx, HttpConnection connection, HttpRequest request,
            RequestFlags effectiveFlags, CancellationToken cancellationToken)
        {
            await CompletedTask.ConfigureAwait(false);

            Debug(ctx, 2, "HANDLE POST", request.Path, request.Method, effectiveFlags);

            if (request.Headers.ContainsKey("X-Mono-Redirected"))
            {
                effectiveFlags |= RequestFlags.Redirected;
            }

            if ((effectiveFlags & RequestFlags.RedirectedAsGet) != 0)
            {
                if (!ctx.Expect(request.Method, Is.EqualTo("GET"), "method"))
                {
                    return(null);
                }
            }
            else if (Method != null)
            {
                if (!ctx.Expect(request.Method, Is.EqualTo(Method), "method"))
                {
                    return(null);
                }
            }
            else
            {
                if (!ctx.Expect(request.Method, Is.EqualTo("POST").Or.EqualTo("PUT"), "method"))
                {
                    return(null);
                }
            }

            if (customHandler != null)
            {
                var customResponse = customHandler(request);
                if (customResponse != null)
                {
                    return(customResponse);
                }
            }

            if ((effectiveFlags & RequestFlags.RedirectedAsGet) != 0)
            {
                ctx.Expect(request.ContentLength, Is.Null, "Content-Length header not allowed");
                ctx.Expect(request.TransferEncoding, Is.Null, "Transfer-Encoding header not allowed");
                return(HttpResponse.CreateSuccess());
            }

            if ((effectiveFlags & RequestFlags.NoContentLength) != 0)
            {
                ctx.Expect(request.ContentLength, Is.Null, "Content-Length header not allowed");
                ctx.Expect(request.TransferEncoding, Is.Null, "Transfer-Encoding header not allowed");
            }

            Debug(ctx, 2, "HANDLE POST #1", request.ContentLength, request.TransferEncoding);

            switch (Mode)
            {
            case TransferMode.Default:
                if (Content != null)
                {
                    ctx.Expect(request.ContentLength, Is.Not.Null, "Missing Content-Length");
                    break;
                }
                else
                {
                    ctx.Expect(request.ContentLength, Is.Null, "Content-Length header not allowed");
                    return(HttpResponse.CreateSuccess());
                }

            case TransferMode.ContentLength:
                ctx.Expect(request.ContentLength, Is.Not.Null, "Missing Content-Length");
                ctx.Expect(request.TransferEncoding, Is.Null, "Transfer-Encoding header not allowed");
                break;

            case TransferMode.Chunked:
                if ((effectiveFlags & RequestFlags.Redirected) != 0)
                {
                    goto case TransferMode.ContentLength;
                }

                ctx.Expect(request.ContentLength, Is.Null, "Content-Length header not allowed");
                var ok = ctx.Expect(request.TransferEncoding, Is.Not.Null, "Missing Transfer-Encoding header");
                if (!ok)
                {
                    break;
                }

                ok &= ctx.Expect(request.TransferEncoding.ToLowerInvariant(), Is.EqualTo("chunked"), "Invalid Transfer-Encoding");
                break;

            default:
                ctx.Expect(false, "Unknown TransferMode: '{0}'", Mode);
                return(null);
            }

            Debug(ctx, 5, "BODY", request.Body);
            if ((effectiveFlags & RequestFlags.NoBody) != 0)
            {
                ctx.Expect(HttpContent.IsNullOrEmpty(request.Body), "Must not send a body with this request.");
                return(null);
            }

            if (Content != null)
            {
                HttpContent.Compare(ctx, request.Body, Content, true);
            }
            else
            {
                ctx.Expect(HttpContent.IsNullOrEmpty(request.Body), "null or empty content");
            }

            return(null);
        }
        public static string CalculateMoveRequestTypeForMigration(object mailboxMoveFlags)
        {
            RequestFlags requestFlags = WinformsHelper.ParseRequestFlags(mailboxMoveFlags.ToString());

            return(((requestFlags & RequestFlags.CrossOrg) != RequestFlags.None) ? Strings.MoveRequestTypeCrossOrg : Strings.MoveRequestTypeIntraOrg);
        }
Exemple #14
0
 protected internal override HttpResponse HandleRequest(TestContext ctx, HttpConnection connection, HttpRequest request, RequestFlags effectiveFlags)
 {
     ctx.Assert(request.Method, Is.EqualTo("GET"), "method");
     return(new HttpResponse(HttpStatusCode.OK, Content));
 }
Exemple #15
0
 private static extern bool SQLConfigDataSourceW(UInt32 hwndParent, RequestFlags fRequest, string lpszDriver, string lpszAttributes);
Exemple #16
0
 private bool GetRequestFlag(ReqFlags flag)
 {
     return(RequestFlags.HasFlag(flag));
 }
Exemple #17
0
 private static extern bool SQLConfigDataSourceW(UInt32 hwndParent, RequestFlags fRequest, string lpszDriver, string lpszAttributes);
Exemple #18
0
        protected internal override HttpResponse HandleRequest(HttpConnection connection, HttpRequest request, RequestFlags effectiveFlags)
        {
            if (!request.Method.Equals("GET"))
            {
                return(HttpResponse.CreateError("Wrong method: {0}", request.Method));
            }

            return(HttpResponse.CreateSuccess(string.Format("Hello World {0}!", ++next_id)));
        }
        bool HandlePostRequest(Connection connection, RequestFlags effectiveFlags)
        {
            Debug (0, "HANDLE POST", connection.Path, connection.Method, effectiveFlags);

            if ((effectiveFlags & RequestFlags.RedirectedAsGet) != 0) {
                if (!connection.Method.Equals ("GET")) {
                    WriteError (connection, "Wrong method: {0}", connection.Method);
                    return false;
                }
            } else {
                if (!connection.Method.Equals ("POST") && !connection.Method.Equals ("PUT")) {
                    WriteError (connection, "Wrong method: {0}", connection.Method);
                    return false;
                }
            }

            return CheckTransferMode (connection, effectiveFlags);
        }
Exemple #20
0
 protected internal abstract HttpResponse HandleRequest(TestContext ctx, HttpConnection connection, HttpRequest request, RequestFlags effectiveFlags);
        /// <summary>
        ///     This overload of GetValue assumes that entryIndex is valid. 
        ///      It also does not do the check storage on the InheritanceParent.
        /// </summary> 
        private EffectiveValueEntry GetEffectiveValue( 
            EntryIndex          entryIndex,
            DependencyProperty  dp, 
            RequestFlags        requests)
        {
            EffectiveValueEntry entry = _effectiveValues[entryIndex.Index];
            EffectiveValueEntry effectiveEntry = entry.GetFlattenedEntry(requests); 

            if (((requests & (RequestFlags.DeferredReferences | RequestFlags.RawEntry)) != 0) || !effectiveEntry.IsDeferredReference) 
            { 
                return effectiveEntry;
            } 

            if (!entry.HasModifiers)
            {
                // For thread-safety, sealed DOs can't modify _effectiveValues. 
                Debug.Assert(!DO_Sealed, "A Sealed DO cannot be modified");
 
                if (!entry.HasExpressionMarker) 
                {
                    // The value for this property was meant to come from a dictionary 
                    // and the creation of that value had been deferred until this
                    // time for better performance. Now is the time to actually instantiate
                    // this value by querying it from the dictionary. Once we have the
                    // value we can actually replace the deferred reference marker 
                    // with the actual value.
                    DeferredReference reference = (DeferredReference)entry.Value; 
                    object value = reference.GetValue(entry.BaseValueSourceInternal); 

                    if (!dp.IsValidValue(value)) 
                    {
                        throw new InvalidOperationException(SR.Get(SRID.InvalidPropertyValue, value, dp.Name));
                    }
 
                    // Make sure the entryIndex is in [....] after
                    // the inflation of the deferred reference. 
                    entryIndex = CheckEntryIndex(entryIndex, dp.GlobalIndex); 

                    entry.Value = value; 

                    _effectiveValues[entryIndex.Index] = entry;
                    return entry;
                } 
            }
            else 
            { 
                // The value for this property was meant to come from a dictionary
                // and the creation of that value had been deferred until this 
                // time for better performance. Now is the time to actually instantiate
                // this value by querying it from the dictionary. Once we have the
                // value we can actually replace the deferred reference marker
                // with the actual value. 

                ModifiedValue modifiedValue = entry.ModifiedValue; 
                DeferredReference reference = null; 
                bool referenceFromExpression = false;
 
                if (entry.IsCoercedWithCurrentValue)
                {
                    if (!entry.IsAnimated)
                    { 
                        reference = modifiedValue.CoercedValue as DeferredReference;
                    } 
                } 

                if (reference == null && entry.IsExpression) 
                {
                    if (!entry.IsAnimated && !entry.IsCoerced)
                    {
                        reference = (DeferredReference) modifiedValue.ExpressionValue; 
                        referenceFromExpression = true;
                    } 
                } 

                Debug.Assert(reference != null, "the only modified values that can have deferredreferences are (a) expression, (b) coerced control value"); 
                if (reference == null)
                {
                    return effectiveEntry;
                } 

                object value = reference.GetValue(entry.BaseValueSourceInternal); 
 
                if (!dp.IsValidValue(value))
                { 
                    throw new InvalidOperationException(SR.Get(SRID.InvalidPropertyValue, value, dp.Name));
                }

                // Make sure the entryIndex is in [....] after 
                // the inflation of the deferred reference.
                entryIndex = CheckEntryIndex(entryIndex, dp.GlobalIndex); 
 
                if (referenceFromExpression)
                { 
                    entry.SetExpressionValue(value, modifiedValue.BaseValue);
                }
                else
                { 
                    entry.SetCoercedValue(value, null, true /* skipBaseValueChecks */, entry.IsCoercedWithCurrentValue);
                } 
 
                _effectiveValues[entryIndex.Index] = entry;
 
                effectiveEntry.Value = value;
            }
            return effectiveEntry;
        } 
Exemple #22
0
 public RecipientWrapper(ADObjectId id, RequestStatus moveStatus = RequestStatus.None, string moveBatchName = null, RequestFlags requestFlags = RequestFlags.None, RecipientType recipientType = RecipientType.UserMailbox, RecipientTypeDetails recipientTypeDetails = RecipientTypeDetails.None)
 {
     this.Id                   = id;
     this.MoveStatus           = moveStatus;
     this.MailboxMoveBatchName = moveBatchName;
     this.RequestFlags         = requestFlags;
     this.RecipientType        = recipientType;
     this.RecipientTypeDetails = recipientTypeDetails;
 }