void OperationContext_GlobalSendingRequest(object sender, RequestEventArgs e) { if (e.Request.ContentLength < 0) { e.Request.ContentLength = 0; } }
private void OnUnsubscribeNotifications(object sender, RequestEventArgs <v12.Protocol.StoreNotification.UnsubscribeNotifications, Guid> args) { Store.ExecuteWithLock(() => { OnUnsubscribeNotificationsCore(sender, args); }); }
private static void HandleRequest(RequestEventArgs e) { e.Response.StatusCode = 200; e.Response.StatusText = "kay"; // cache for easier benchmarking against iis (caches files < 256 KB). if (_cache == null) { e.Response.ContentStream = new MemoryStream(); e.Response.StartHtml("Niob"); e.Response.AppendHtml("<h1>Niob</h1>"); e.Response.AppendHtml("<p>Small and efficient webserver for embedding in your application.</p>"); e.Response.AppendHtml("<p>This page is 128 KiB big.</p>"); e.Response.AppendHtml("\n<!--|"); e.Response.AppendHtml("".PadLeft(128*1024 - 235, ' ')); e.Response.AppendHtml("|"); e.Response.AppendHtml("-->\n"); e.Response.EndHtml(); _cache = ((MemoryStream) e.Response.ContentStream).ToArray(); } else { e.Response.ContentStream = new MemoryStream(_cache); } e.Response.Send(); }
private static void ServiceClientBeforeRequestEvent(object sender, RequestEventArgs e) { if (e is WebServiceRequestEventArgs args && args.Headers.ContainsKey(UserAgentHeader)) { args.Headers[UserAgentHeader] = args.Headers[UserAgentHeader] + " SSMConfigProvider/" + AssemblyVersion; } }
public bool Handle(RequestEventArgs e) { NetworkRequest req = Multiplexor.Decode(e.Request); logger.Trace("Server rx: {0} p: {1} source: {2} overlord: {3}", req.Verb, req.Param, req.SourceID, req.OverlordID); switch (req.Verb) { case "INFO": return(HandleClient(req, e)); case "CONNECT": return(HandleConnect(req, e)); case "CHAT": return(HandleChat(req, e)); case "COMPARE": return(HandleCompare(e, req)); case "SEARCH": return(HandleSearch(e, req)); case "UPDATE": return(HandleUpdate(e, req)); case "NOOP": return(HandleNOOP(e, req)); } return(false); }
private void SendOk(RequestEventArgs e) { e.Response.Status = HttpStatusCode.OK; var generator = new ResponseWriter(); generator.SendHeaders(e.Context, e.Response); }
private void Page_RequestFinished(object sender, RequestEventArgs e) { if (DebugInfo) { Console.WriteLine($"Page_RequestFinished: [{e.Request?.Method}] {e.Request?.Url}"); } }
private void Page_RequestServedFromCache(object sender, RequestEventArgs e) { if (DebugInfo) { Console.WriteLine($"Page_RequestServedFromCache: [{e.Request?.Method}] {e.Request?.Url}"); } }
public void OnRequest(object sender, RequestEventArgs e) { if (!e.Data.ToString().Equals("test")) { return; } }
public void OnRequestDesbloqueio(object sender, RequestEventArgs e) { e.Response.Connection.Type = ConnectionType.Close; e.Response.ContentType.Value = "text/xml"; if (unlockSent == 0) { unlockSent++; string opcionais = ""; int numparams = 1; if (checkBox1.Checked) { opcionais += "<ParameterValueStruct><Name>InternetGatewayDevice.Services.X_Pace_Com.Services.SSH.Enable</Name><Value xsi:type=\"xsd:unsignedInt\">1</Value></ParameterValueStruct>"; numparams++; } timer1.Stop(); AppendTextBox("\r\nModem conectado, enviando configuração.\r\n"); byte[] buffer = Encoding.Default.GetBytes("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<soap-env:Envelope xmlns:soap-enc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:soap-env=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:cwmp=\"urn:dslforum-org:cwmp-1-0\"><soap-env:Header><cwmp:ID soap-env:mustUnderstand=\"1\">55882f2177ab936c3f062f8f</cwmp:ID></soap-env:Header><soap-env:Body><cwmp:SetParameterValues><ParameterList soap-enc:arrayType=\"cwmp:ParameterValueStruct[" + numparams + "]\"><ParameterValueStruct><Name>InternetGatewayDevice.Services.X_Pace_Com.Services.GvtConfig.AccessClass</Name><Value xsi:type=\"xsd:unsignedInt\">" + runLevel + "</Value></ParameterValueStruct>" + opcionais + "</ParameterList><ParameterKey/></cwmp:SetParameterValues></soap-env:Body></soap-env:Envelope>"); e.Response.Body.Write(buffer, 0, buffer.Length); AppendTextBox("Finalizado.\r\n"); } else if (unlockSent < 2) { unlockSent++; byte[] buffer = Encoding.Default.GetBytes("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<soap-env:Envelope xmlns:soap-enc=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:soap-env=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:cwmp=\"urn:dslforum-org:cwmp-1-0\"><soap-env:Header><cwmp:ID soap-env:mustUnderstand=\"1\">null</cwmp:ID></soap-env:Header><soap-env:Body><cwmp:InformResponse><MaxEnvelopes>1</MaxEnvelopes></cwmp:InformResponse></soap-env:Body></soap-env:Envelope>"); e.Response.Body.Write(buffer, 0, buffer.Length); } else { unlockSent = 1; e.Response.Status = HttpStatusCode.NoContent; } }
private void OnGetObject(object sender, RequestEventArgs <v11.Protocol.Store.GetObject, v11.Datatypes.Object.DataObject> args) { Store.ExecuteWithLock(() => { OnGetObjectCore(sender, args); }); }
private void listener_RequestReceived(object sender, RequestEventArgs e) { e.IsHandled = true; e.Response.Reason = string.Empty; string userAgent = string.Empty; IHeader uahead = e.Request.Headers.Where(h => string.Equals("User-Agent", h.Name, StringComparison.OrdinalIgnoreCase)). FirstOrDefault(); if (null != uahead) { userAgent = uahead.HeaderValue; } //Send to the correct handler if (userAgent.StartsWith("FAP")) { if (OnRequest(RequestType.FAP, e)) { return; } } if (OnRequest(RequestType.HTTP, e)) { return; } e.Response.Reason = "Handler error"; e.Response.Status = HttpStatusCode.InternalServerError; var generator = new ResponseWriter(); generator.SendHeaders(e.Context, e.Response); }
/// <summary> /// Called when the <see cref="HttpListener"/> receives a request /// </summary> /// <param name="sender">Sender of the request</param> /// <param name="e">RequestEventArgs received</param> protected virtual void OnRequest(object sender, RequestEventArgs e) { var obj = ProcessRequest(sender, e); if (obj == null) { throw new NullReferenceException("obj"); } if (OnRestRequestCall(e)) { return; } var str = JsonConvert.SerializeObject(obj, Formatting.Indented); var jsonp = e.Request.Parameters["jsonp"]; if (!string.IsNullOrWhiteSpace(jsonp)) { str = string.Format("{0}({1});", jsonp, str); } e.Response.Connection.Type = ConnectionType.Close; e.Response.ContentType = new ContentTypeHeader("application/json; charset=utf-8"); e.Response.Add(serverHeader); var bytes = Encoding.UTF8.GetBytes(str); e.Response.Body.Write(bytes, 0, bytes.Length); e.Response.Status = HttpStatusCode.OK; }
internal void FireBeforeRequestEvent(object sender, RequestEventArgs args) { if (BeforeRequestEvent != null) { BeforeRequestEvent(sender, args); } }
private static async void Page_Request(object sender, RequestEventArgs e) { //if (e.Request.Url.Contains("google")) //{ // // //await e.Request.AbortAsync(); // Log.Error(e.Request.Url); // if (e.Request.Method == HttpMethod.Post) // { // Log.Error(e.Request.PostData); // } // await e.Request.ContinueAsync(); //} //else //{ // Log.Info(e.Request.Url); // if (e.Request.Method == HttpMethod.Post) // { // Log.Info(e.Request.PostData); // } // await e.Request.ContinueAsync(); //} await e.Request.ContinueAsync(); //var payload = new Payload() //{ // Url = "https://httpbin.org/forms/post", // Method = HttpMethod.Post /*, // PostData = keyValuePairs*/ //}; //await e.Request.ContinueAsync(payload); }
// Protected protected void OnRequest( object source, RequestEventArgs args) { HttpClientContext context = (HttpServer.HttpClientContext)source; context.Stream.ReadTimeout = RequestReadWriteTimeout; context.Stream.WriteTimeout = RequestReadWriteTimeout; HttpRequest request = (HttpRequest)args.Request; // DEBUG OUTPUT System.Console.WriteLine( "Connection acccepted from " + context.RemoteAddress); System.Console.WriteLine(request.Method); System.Console.WriteLine(request.Uri); foreach (String nextKey in request.Headers.Keys) { System.Console.WriteLine( nextKey + "=" + request.Headers[nextKey]); } System.Console.WriteLine(); // Handle methods switch (request.Method) { case "GET": HandleGetRequest(context, request); break; case "PUT": HandlePutRequest(context, request); break; case "DELETE": HandleDeleteRequest(context, request); break; case "COPY": case "MOVE": HandleCopyOrMoveRequest(context, request); break; case "SETMANIFESTINFO": HandleSetManifestInfoRequest(context, request); break; case "SETFILEINFO": HandleSetFileInfoRequest(context, request); break; } }
public void OnRequest(object sender, RequestEventArgs e) { if (e.Data != typeof(EventArgs)) { return; } Messenger.SendMessage(e.From, EventArgs.Empty); }
private void SendError(RequestEventArgs e) { e.Response.Status = HttpStatusCode.MethodNotAllowed; e.Response.ContentLength.Value = 0; var generator = new ResponseWriter(); generator.SendHeaders(e.Context, e.Response); }
private bool HandleClient(NetworkRequest r, RequestEventArgs e) { var verb = new InfoVerb(); verb.Node = serverNode; SendResponse(e, Encoding.UTF8.GetBytes(verb.CreateRequest().Data)); return(true); }
public void OnRequest(object sender, RequestEventArgs e) { if (e.Data != typeof(EventArgs)) { return; } Messenger.SendMessage(e.Sender, new ResolveEventArgs("Test")); }
private void SetDryRunParameterCallback(object sender, RequestEventArgs args) { WebServiceRequestEventArgs wsrea = args as WebServiceRequestEventArgs; if (wsrea != null) { wsrea.Parameters["DryRun"] = "true"; } }
private void OnRequest(object source, RequestEventArgs args) { IHttpClientContext client = (IHttpClientContext)source; IHttpRequest request = args.Request; ++_counter; _request = (IHttpRequest) request.Clone(); _event.Set(); }
void ServiceClientBeforeRequestEvent(object sender, RequestEventArgs e) { var args = e as Amazon.Runtime.WebServiceRequestEventArgs; if (args == null || !args.Headers.ContainsKey(UserAgentHeader)) return; args.Headers[UserAgentHeader] = args.Headers[UserAgentHeader] + " AWSLogger/" + _logType; }
internal virtual void OnRequestBegin(RequestEventArgs e) { EventHandler <RequestEventArgs> handler = RequestBegin; if (handler != null) { handler(null, e); } }
internal virtual void OnRequestComplete(RequestEventArgs e) { EventHandler <RequestEventArgs> complete = RequestComplete; if (complete != null) { complete(null, e); } }
private void OnRequest(object source, RequestEventArgs args) { IHttpClientContext client = (IHttpClientContext)source; IHttpRequest request = args.Request; ++_counter; _request = (IHttpRequest)request.Clone(); _event.Set(); }
private static RequestEventArgs GenerateRequestEventArgs <T>(ExecutionState <T> executionState) { RequestEventArgs args = new RequestEventArgs(executionState.Cmd.CurrentResult); args.Request = executionState.Req; args.Response = executionState.Resp; return(args); }
public override void requestInformation(RequestEventArgs e) { switch (e.info_type) { default: base.requestInformation(e); return; } }
protected virtual void OnRequestEnded(RequestEventArgs e) { EventHandler <RequestEventArgs> handler = RequestEnded; if (handler != null) { handler(this, e); } }
void OnReceiveModuleRequest(object sender, RequestEventArgs e) { System.Diagnostics.Debug.WriteLine("{0} {1} {2}", e.Sender, e.From, e.Data); var fromModule = Container.Get(e.From); var senderModule = Container.Get(e.Sender); var toInvoke = BaseMessenger <IModuleService> .ResolveRequestMethod(e, "OnRequest"); toInvoke?.Invoke(fromModule, new object[] { senderModule, e }); }
private void PageRequest(object sender, RequestEventArgs e) { if (!e.Request.IsNavigationRequest) { return; } Interlocked.Increment(ref _pendingNavigationRequestCount); }
protected virtual void OnRequestComplete(RequestEventArgs e) { EventHandler <RequestEventArgs> complete = RequestComplete; if (complete != null) { complete(this, e); } }
private void OnRequest(object sender, RequestEventArgs e) { Assert.Equal(_request.To, e.Request.To); Assert.Equal(_request.From, e.Request.From); Assert.Equal(_request.Contact, e.Request.Contact); Assert.Equal(_request.CallId, e.Request.CallId); Assert.Equal(_request.CSeq, e.Request.CSeq); Assert.Equal(_request.MaxForwards, e.Request.MaxForwards); _manualEvent.Set(); }
public bool Invoke(string method, string source, RequestEventArgs args) { List<EventHandler<RequestEventArgs>> items = GetList(method); if (items == null) return false; lock (items) foreach (var handler in items) handler(source, args); return items.Count > 0; }
protected override void OnRequestReceived(RequestEventArgs<Message, Message> rea) { base.OnRequestReceived(rea); if ((rea.Request.ID == requestId && rea.Request.QueryResponse == Qr.Answer) || rea.Request.ID == 0) { if (AnswerReceived != null) AnswerReceived(rea.Request.Clone()); } if ((rea.Request.ID != requestId || rea.Request.ID == 0) && rea.Request.QueryResponse == Qr.Query) { this.requestId = 0; Message response = rea.Request.Clone(); response.From = rea.Host; if (QueryReceived != null) QueryReceived(response); if (response.AnswerEntries > 0) rea.Response = response; } }
private void RequestComplete(object sender, RequestEventArgs e) { Invoke(new MethodInvoker(() => AddLogRows(new[] { e.RequestLog, e.ResponseLog }))); }
protected virtual string OnRequest(RequestEventArgs args) { if (Request != null) return Request(this, args); return ""; }
private void OnRequest(object sender, RequestEventArgs e) { _request = e.Request; }
void session_Request(object sender, RequestEventArgs e) { Debug.WriteLine(String .Format("REQUEST: {0} {1} - message: {2}", e.Method, e.Url, e.Message)); }
/// <summary> /// Handles the internal request. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="RequestEventArgs"/> instance containing the event data.</param> private void HandleRequest(object sender, RequestEventArgs e) { Route route = null; // create request/response Request req = new Request(e.Request); Response res = new Response(e.Response); // name header e.Response.Headers["X-Karambit-App"] = name; // middleware foreach (Middleware mware in middleware) { // invoke middleware bool handled = (bool)mware.Function.Invoke(null, new object[] { req, res }); // check if handed if (handled) { if (Deployment == Deployment.Production) Logger.Log(LogLevel.Information, "http", req.Method + " " + req.Path); return; } } // find route foreach (Route r in routes) { if (r.Path == req.Path && r.Method == req.Method) { route = r; break; } } // check found if (route == null) { res.StatusCode = HttpStatus.NotFound; res.Write("Cannot " + req.Method + " " + req.Path); // log goto fail; } // parameters ParameterInfo[] parameters = route.Function.GetParameters(); object[] parameterValues = new object[parameters.Length]; // request and response parameterValues[0] = req; parameterValues[1] = res; // iterate for (int i = 2; i < parameters.Length; i++) { // get parameter ParameterInfo info = parameters[i]; bool hasParameter = req.Query.ContainsKey(info.Name); if (!info.HasDefaultValue && !hasParameter) { // missing parameter and no default value res.StatusCode = HttpStatus.BadRequest; res.Write("The parameter " + info.Name + " is missing from the request"); goto fail; } else if (info.HasDefaultValue && !hasParameter) { // missing parameter has default value parameterValues[i] = info.DefaultValue; } else { // parameter exists Utilities.DynamicParse(req.Query[info.Name], info.ParameterType, out parameterValues[i]); } } // log if (Deployment == Deployment.Production) Logger.Log(LogLevel.Information, "http", req.Method + " " + req.Path); // invoke route.Function.Invoke(null, parameterValues); return; // fail message fail: if (Deployment == Deployment.Production) Logger.Log(LogLevel.Error, "http", req.Method + " " + req.Path); }
private void SendingRequest(object sender, RequestEventArgs e) { if (this.error == null) { StorageLocation location = (this.requestCounter == 0) ? this.initialLocation : this.retryInfoList[this.requestCounter - 1].TargetLocation; Uri uri = this.storageUri.GetUri(location); if (!e.RequestUri.AbsoluteUri.StartsWith(uri.AbsoluteUri)) { this.error = string.Format("Request {0} was sent to {1} while the host should have been {2}", this.requestCounter, e.RequestUri, uri); } } this.requestCounter++; }
private static void HandleRequestAsync(object sender, RequestEventArgs e) { // this is just an example, you don't need to do that. // however if you don't your worker thread(s) will be clogged. Task.Factory.StartNew(HandleRequestSafe, e); }
private void OnIncomingRequest(object source, RequestEventArgs args) { IHttpClientContext client = (IHttpClientContext)source; IHttpRequest request = args.Request; client.Respond("Hello world!"); ++_currentThreadCount; _testEvent.Set(); }
/// <summary> /// Raises the <see cref="E:Request" /> event. /// </summary> /// <param name="e">The <see cref="RequestEventArgs"/> instance containing the event data.</param> internal virtual void OnRequest(RequestEventArgs e) { if (Request != null) Request(this, e); }
void Server_RequestComplete(object sender, RequestEventArgs e) { }
/// <summary> /// Received a request from the other end. /// </summary> /// <param name="request"></param> public void OnRequest(object sender, RequestEventArgs e) { }
/// <summary> /// Raise connect request event /// </summary> protected void OnRequest(RequestEventArgs e) { if (Request != null) Request(this, e); }
protected virtual void OnRequestComplete(RequestEventArgs e) { EventHandler<RequestEventArgs> complete = RequestComplete; if (complete != null) complete(this, e); }
public override ResponseInfo HandleRequest(RequestInfo request) { var args = new RequestEventArgs { Request = request }; OnProcessRequest(args); return args.Response; }
private IServiceResponse FireRequestReceived(IServiceRequest request) { EventHandler<RequestEventArgs> h = RequestReceived; if (h != null) { RequestEventArgs e = new RequestEventArgs(request); IServiceResponse response = new JsonResponse(new JObject()); response.StatusCode = 200; e.Response = response; h(this, e); return e.Response; } return null; }
protected virtual void OnProcessRequest(RequestEventArgs e) { EventHandler<RequestEventArgs> handler = ProcessRequest; if (handler != null) handler(this, e); }
protected virtual void OnRequestBegin(RequestEventArgs e) { EventHandler<RequestEventArgs> handler = RequestBegin; if (handler != null) handler(this, e); }
private void OnRequest(object sender, RequestEventArgs e) { RequestReceived(this, e); }
private void OnRequest(object sender, RequestEventArgs e) { /* RFC 3581 4. When a server compliant to this specification (which can be a proxy or UAS) receives a request, it examines the topmost Via header field value. If this Via header field value contains an "rport" parameter with no value, it MUST set the value of the parameter to the source port of the request. This is analogous to the way in which a server will insert the "received" parameter into the topmost Via header field value. In fact, the server MUST insert a "received" parameter containing the source IP address that the request came from, even if it is identical to the value of the "sent-by" component. Note that this processing takes place independent of the transport protocol. */ ViaEntry via = e.Request.Via.First; var ep = e.RemoteEndPoint as IPEndPoint; if (ep != null) { via.Received = ep.Address.ToString(); if (via.RportWanted) via.Rport = ep.Port; } /* RFC 3261 18.2.1. When the server transport receives a request over any transport, it MUST examine the value of the "sent-by" parameter in the top Via header field value. If the host portion of the "sent-by" parameter contains a domain name, or if it contains an IP address that differs from the packet source address, the server MUST add a "received" parameter to that Via header field value. This parameter MUST contain the source address from which the packet was received. This is to assist the server transport layer in sending the response, since it must be sent to the source IP address from which the request came. Next, the server transport attempts to match the request to a server transaction. It does so using the matching rules described in Section 17.2.3. If a matching server transaction is found, the request is passed to that transaction for processing. If no match is found, the request is passed to the core, which may decide to construct a new server transaction for that request. Note that when a UAS core sends a 2xx response to INVITE, the server transaction is destroyed. This means that when the ACK arrives, there will be no matching server transaction, and based on this rule, the ACK is passed to the UAS core, where it is processed. */ //_logger.Debug(GetMessage(e.Request)); RequestReceived(this, e); }