private void MoveRequestsFromPendingResponseToSend(SystemChannel system, RequestPhase phase, PendingMapType pendingMap) { List <uint> list = new List <uint>(); List <uint> list2 = new List <uint>(); foreach (KeyValuePair <uint, ClientRequestType> pair in this.m_state.m_contextIdToRequestMap) { uint key = pair.Key; ClientRequestType type = pair.Value; if ((type.System.SystemId == system.SystemId) && (phase == type.Phase)) { if (type.ShouldRetryOnError) { list.Add(key); } else { list2.Add(key); } } } foreach (uint num2 in list) { string reason = (phase != RequestPhase.STARTUP) ? "moving_to_pending_running_phase" : "moving_to_pending_startup_phase"; ClientRequestType item = this.GetClientRequest(num2, reason, true); pendingMap.PendingSend.Enqueue(item); this.m_state.m_contextIdToDroppedPacketMap.Add(num2, item); } foreach (uint num3 in list2) { ClientRequestType type3 = this.GetClientRequest(num3, "moving_to_dropped", true); this.m_state.m_contextIdToDroppedPacketMap.Add(num3, type3); } }
private IEnumerable <JavascriptModifier> GetModifiers(HttpContext context, RequestPhase phase) { var modifierCollection = _modifierOptions.Value.Modifiers.Where(modifier => modifier.RequestPhase == phase); if (phase == RequestPhase.Request) { modifierCollection = string.IsNullOrEmpty(context.Request.ContentType) ? modifierCollection.Where(modifier => string.IsNullOrEmpty(modifier.TargetContentType)) : modifierCollection.Where(modifier => !string.IsNullOrEmpty(modifier.TargetContentType) && context.Request.ContentType.Contains(modifier.TargetContentType)); } else if (phase == RequestPhase.Response) { modifierCollection = string.IsNullOrEmpty(context.Response.ContentType) ? modifierCollection.Where(modifier => string.IsNullOrEmpty(modifier.TargetContentType)) : modifierCollection.Where(modifier => !string.IsNullOrEmpty(modifier.TargetContentType) && context.Response.ContentType.Contains(modifier.TargetContentType)); } return(modifierCollection.OrderBy(modifier => modifier.Priority)); }
private bool SendClientRequestImpl(int type, IProtoBuf body, ClientRequestConfig clientRequestConfig, RequestPhase requestPhase, int subID) { if (type == 0) { return(false); } if ((requestPhase < RequestPhase.STARTUP) || (requestPhase > RequestPhase.RUNNING)) { return(false); } ClientRequestConfig config = (clientRequestConfig != null) ? clientRequestConfig : this.m_defaultConfig; int requestedSystem = config.RequestedSystem; SystemChannel orCreateSystem = this.GetOrCreateSystem(requestedSystem); if (requestPhase < orCreateSystem.CurrentPhase) { return(false); } if (orCreateSystem.WasEverInRunningPhase && (requestPhase < RequestPhase.RUNNING)) { return(false); } if (body == null) { return(false); } ClientRequestType item = new ClientRequestType { Type = type, ShouldRetryOnError = config.ShouldRetryOnError, SubID = subID, Body = ProtobufUtil.ToByteArray(body), Phase = requestPhase, RetryCount = 0, RequestId = this.GetNextRequestId() }; if (item.Phase == RequestPhase.STARTUP) { orCreateSystem.Phases.StartUp.PendingSend.Enqueue(item); } else { orCreateSystem.Phases.Running.PendingSend.Enqueue(item); } return(true); }
public bool SendClientRequest(int type, IProtoBuf body, ClientRequestConfig clientRequestConfig, RequestPhase requestPhase = 1, int subID = 0) { return(this.SendClientRequestImpl(type, body, clientRequestConfig, requestPhase, subID)); }
private async Task <ModificationContext> GetModificationContext(HttpContext context, RequestPhase phase) { ModificationContext modificationContext = null; if (phase == RequestPhase.Request) { var requestBodyBuffer = new MemoryStream(); await context.Request.Body.CopyToAsync(requestBodyBuffer); requestBodyBuffer.Seek(0, SeekOrigin.Begin); return(new ModificationContext(requestBodyBuffer, context.Request.ContentType)); } if (phase == RequestPhase.Response) { var responseStreamBuffer = context.Response.Body; responseStreamBuffer.Position = 0; return(new ModificationContext(responseStreamBuffer, context.Response.ContentType)); } return(modificationContext); }