public ListenerService(IContainer c, bool _isServer) { container = c; http = c.Resolve <HTTPHandler>(); isServer = _isServer; model = container.Resolve <Model>(); }
public dynamic RequiredJsonField(string field_name, JTokenType type) { dynamic value = null; if (json == null) { json = HTTPHandler.JsonRequest(ref data, ref remoteSocket); } if (json != null) { if (HTTPHandler.RequiredJsonField(ref json, ref field_name, ref type, ref remoteSocket, ref value)) { return(value); } else { ReturnedValue(ref value, type); return(value); } } else { ReturnedValue(ref value, type); return(value); } }
private static void EventLogWritten(object source, EntryWrittenEventArgs e) { if (e.Entry.EntryType != EventLogEntryType.Error) { return; } Logger.Debug("EventLog written"); string message = e.Entry.Message; Match match = new Regex("(HD-.+).exe").Match(message); if (!match.Success) { return; } string str = match.Groups[1].Value; Logger.Info("Event log for {0} written", (object)str); Logger.Info("Message:\n{0}", (object)message); try { if (!HDAgent.sOemWindowMapper.ContainsKey(Oem.Instance.OEM) || str.Equals("HD-Agent", StringComparison.CurrentCultureIgnoreCase)) { return; } HTTPHandler.StartLogCollection("EXE_CRASHED", "binName"); HDAgent.NotifyExeCrashToParentWindow(HDAgent.sOemWindowMapper[Oem.Instance.OEM][0], HDAgent.sOemWindowMapper[Oem.Instance.OEM][1]); } catch (Exception ex) { Logger.Error(string.Format("Error Occured, Err: {0}", (object)ex.ToString())); } }
static void Main(string[] args) { var ebp = new HTTPHandler(null, null); ebp.Start(); Console.ReadKey(); ebp.Stop(); }
public string HeadParameter(string field_name) { string value = HTTPHandler.GetHeadParamRequest(ref data, field_name); if (value == null) { value = ""; } return(value); }
public void sendRawTest() { string raw = "STX=YES&VERBOSE=YES&CONTENTTYPE=XML&APISignature=%24&APIFormat=0&AccessToken=390B2B95-E74C-4774-A88B-C07E5B020488&APIOptions=ALLDATA%2CALLOWPARTIALAUTH%2CBYPASSAMOUNTOK%2CBYPASSSIGCAP%2CENHANCEDRECEIPTS%2CPRINTTIPLINE&Clerk=545&Date=090518&FunctionRequestCode=1B&Invoice=7641&PrimaryAmount=100.00&ReceiptTextColumns=30&RequestorReference=95750500&SaleFlag=S&Time=103132&Vendor=CottaCapital%3AFormSim%3A0.2&CardPresent=Y&CardNumber=4761739001010010&ExpirationDate=1220&CVV2Indicator=1&CVV2Code=333&CustomerName=Sterling+Archer&StreetAddress=65+Main+Street&ZipCode=65000&CustomerReference=randCust64012578&TaxIndicator=N&TaxAmount=0&DestinationZipCode=65000&ProductDescriptor1=Electronics&ProductDescriptor2=A%28%5B%2A%3F6%24b%26C%25d%23%2F1%3D2%5C4%7C%3A%3B%2F%2F%40www.shift4%2B%2C%27%5D%29&Notes=Random+Misc+Notes&ETX=YES"; HTTPHandler handler = new HTTPHandler("D15D6347-E3D6-4BB4-7B5632F470EBC751", "21B00A88-E976-66F2-88EA7F78281AFAE2", "10.0.2.124", "16448"); Dictionary <string, string> res = handler.sendRaw(raw).Result; Assert.AreEqual("N", res["errorindicator"]); Assert.AreEqual("A", res["response"]); Assert.AreEqual("A", res["avsresult"]); }
public string FormField(string field_name) { string value = HTTPHandler.GetContentDispositionValue(ref data, field_name); if (value == null) { value = ""; } return(value); }
public async Task TestCommand() { //use this to test whatever string requestString = @"http://api.champion.gg/champion/ahri/summaaoners/mostWins?api_key=9d30e87ffd52401b8387aa20cf2c701e"; IRestResponse data = HTTPHandler.GET(requestString); MessageHandler messageHandler = new MessageHandler(); await ReplyAsync("", false, messageHandler.BuildEmbed("testing", $"{data.Content}; {data.StatusCode}; {data.StatusDescription}; {data.ResponseStatus}; {data.IsSuccessful}", Palette.Pink).Build()); }
public void HTTPHandlerTest() { HTTPHandler handler = new HTTPHandler(); Assert.IsNull(handler.getAccessToken()); Assert.IsNull(handler.getAuthToken()); Assert.IsNull(handler.getClientGUID()); Assert.IsNull(handler.getIPAddress()); Assert.IsNull(handler.getPort()); Assert.AreEqual("MoToEcom", handler.getMerchantType()); Assert.IsFalse(handler.performTokenExchange().Result); }
void Awake() { if (_instance != null && _instance != this) { Destroy(this.gameObject); } else { _instance = this; DontDestroyOnLoad(this.gameObject); } }
public void HTTPHandlerTest1() { HTTPHandler handler = new HTTPHandler("D15D6347-E3D6-4BB4-7B5632F470EBC751", "21B00A88-E976-66F2-88EA7F78281AFAE2"); Assert.IsNull(handler.getAccessToken()); Assert.IsNull(handler.getIPAddress()); Assert.IsNull(handler.getPort()); Assert.IsNotNull(handler.getAuthToken()); Assert.IsNotNull(handler.getClientGUID()); Assert.AreEqual("D15D6347-E3D6-4BB4-7B5632F470EBC751", handler.getAuthToken()); Assert.AreEqual("21B00A88-E976-66F2-88EA7F78281AFAE2", handler.getClientGUID()); Assert.IsFalse(handler.performTokenExchange().Result); }
public void performTransactionTest5() { HTTPHandler handler = new HTTPHandler("D15D6347-E3D6-4BB4-7B5632F470EBC751", "21B00A88-E976-66F2-88EA7F78281AFAE2", "10.0.2.124", "16448"); Assert.IsTrue(handler.performTokenExchange().Result); parameters.Add("AccessToken", handler.getAccessToken()); // Insert Front End Passed Params here parameters.Add("CardNumber", ""); parameters.Add("ExpirationDate", ""); parameters.Add("CVV2", "333"); parameters.Add("CVV2Indicator", ""); parameters.Add("CardPresent", ""); parameters.Add("StreetAddress", "65 Main Street"); parameters.Add("DestinationZipCode", "65000"); //parameters.Add("CardType", "NotUsed"); parameters.Add("TrackData", ""); parameters.Add("UniqueID", "00093zepbsfqre8z"); parameters.Add("TokenSerial", ""); parameters.Add("APIOptions", "ALLDATA"); parameters.Add("Invoice", "151858447"); parameters.Add("PrimaryAmount", "111.61"); parameters.Add("SaleFlag", "S"); parameters.Add("ZipCode", "65000"); parameters.Add("SecondaryAmount", "0.00"); parameters.Add("FunctionRequestCode", "1D"); parameters.Add("TaxIndicator", "N"); parameters.Add("TaxAmount", "0.00"); //parameters.Add("TranID", ""); parameters.Add("Clerk", "5188"); //parameters.Add("TerminalID", ""); parameters.Add("Date", this.helper.getDate()); parameters.Add("Time", helper.getTime()); parameters.Add("VoidInvalidAVS", "Y"); parameters.Add("VoidInvalidCVV2", "Y"); parameters.Add("RequestorReference", "1350744"); parameters.Add("UseTokenStore", "N"); parameters.Add("UseMetaToken", "N"); parameters.Add("CustomerName", "Tommy Tester"); //parameters.Add("P2PEBlock", ""); parameters.Add("UseBasicTranFlow", "Y"); parameters.Add("UseRollbacks", "N"); parameters.Add("CardDataType", "TrueToken"); // Send the Transaction and get the result parameters.Add("ETX", "YES"); Dictionary <string, string> res = handler.start(parameters).Result; Assert.AreEqual("07", res["functionrequestcode"]); Assert.AreEqual("A", res["response"]); }
public void handle_header_line(string this_line, HTTPHandler handler) { int follow = 0; while (this_line[follow] != ':') { ++follow; } string field_name = this_line.Substring(0, follow); ++follow; while ((follow < this_line.Length) && (this_line[follow] == ' ')) { ++follow; } string content_length_string = this_line.Substring(follow); handler.handleParameter(field_name, content_length_string); if (field_name.ToLower().Equals("Content-Length".ToLower())) { content_length = 0; while (follow < this_line.Length) { if ((this_line[follow] < '0') || (this_line[follow] > '9')) { throw new Exception( "Bad Content-Length field: `" + content_length_string + "'."); } if (content_length > ((Int64.MaxValue - (this_line[follow] - '0')) / 10)) { throw new Exception("Overflow in Content-Length field."); } content_length = ((content_length * 10) + (this_line[follow] - '0')); ++follow; } have_content_length = true; } else if (field_name.ToLower().Equals("Transfer-Encoding".ToLower())) { if (!(this_line.Substring(follow).ToLower().Equals("chunked"))) { throw new Exception("Unsupported Transfer-Encoding field."); } chunked = true; } }
internal static void SetCurrentAppData(HttpListenerRequest req, HttpListenerResponse res) { Logger.Info("In SetCurrentAppData"); try { RequestData request = HTTPUtils.ParseRequest(req); AppHandler.mCurrentAppPackage = request.Data["package"]; AppHandler.mCurrentAppActivity = request.Data["activity"]; Logger.Info("SetCurrentAppData mCurrentAppPackage = " + AppHandler.mCurrentAppPackage); Logger.Info("SetCurrentAppData mCurrentAppActivity = " + AppHandler.mCurrentAppActivity); Logger.Info("Looking for: " + AppHandler.sAppPackage); if (AppHandler.sAppLaunchedFromRunApp || AppHandler.sAppIconName.Contains(AppHandler.mCurrentAppActivity)) { AppHandler.appLaunched = true; AppHandler.sAppLaunchedFromRunApp = false; } if (!Opt.Instance.sysPrep && Oem.Instance.IsSendGameManagerRequest) { string str = request.Data["callingPackage"]; HTTPUtils.SendRequestToClient("appLaunched", new Dictionary <string, string>() { { "package", AppHandler.mCurrentAppPackage }, { "activity", AppHandler.mCurrentAppActivity }, { "callingPackage", str } }, MultiInstanceStrings.VmName, 0, (Dictionary <string, string>)null, false, 1, 0, "bgp"); } if (Features.ExitOnHome() && AppHandler.appLaunched && (AppHandler.mCurrentAppPackage == "com.bluestacks.gamepophome" || AppHandler.mCurrentAppPackage == "com.bluestacks.appmart")) { Logger.Info("Reached home app. Closing frontend."); Environment.Exit(0); } Opengl.HandleAppActivity(AppHandler.mCurrentAppPackage, AppHandler.mCurrentAppActivity); InputMapper.Instance.SetPackage(AppHandler.mCurrentAppPackage); HTTPHandler.WriteSuccessJson(res); } catch (Exception ex) { Logger.Error("Exception in Server SetCurrentAppData. Err : " + ex.ToString()); HTTPHandler.WriteErrorJson(ex.Message, res); } }
public void JsonInContentDisposition(string field_name) { if (json == null) { string str_json = HTTPHandler.GetContentDispositionValue(ref data, field_name); try { json = JsonConvert.DeserializeObject <dynamic>(str_json); } catch (Exception e) { Logger.WriteLog(e.Message, LogLevel.Error); } } }
public void performTokenExchangeTest() { HTTPHandler handler = new HTTPHandler("D15D6347-E3D6-4BB4-7B5632F470EBC751", "21B00A88-E976-66F2-88EA7F78281AFAE2", "10.0.2.124", "16448"); Assert.IsNull(handler.getAccessToken()); Assert.IsNotNull(handler.getIPAddress()); Assert.IsNotNull(handler.getPort()); Assert.IsNotNull(handler.getAuthToken()); Assert.IsNotNull(handler.getClientGUID()); Assert.AreEqual("10.0.2.124", handler.getIPAddress()); Assert.AreEqual("16448", handler.getPort()); Assert.AreEqual("D15D6347-E3D6-4BB4-7B5632F470EBC751", handler.getAuthToken()); Assert.AreEqual("21B00A88-E976-66F2-88EA7F78281AFAE2", handler.getClientGUID()); Assert.IsTrue(handler.performTokenExchange().Result); Assert.AreEqual("390B2B95-E74C-4774-A88B-C07E5B020488", handler.getAccessToken()); }
private static void SetupAndRunApplication(Opt opt) { Program.CheckIfAlreadyRunning(Opt.Instance.h); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (!VMWindow.CheckAndroidFilesIntegrity()) { Logger.Error("Android File Integrity check failed"); Environment.Exit(-2); } TimelineStatsSender.HandleEngineBootEvent(EngineStatsEvent.android_file_integrity_passed.ToString()); InputMapper.RegisterGuestBootLogsHandler(); AndroidService.StartAsync(); HTTPHandler.StartServer(); Program.InitAudioLogger(Logger.GetHdLoggerCallback()); VMWindow vmWindow = new VMWindow(opt.h, opt.w); Application.Run(); }
internal static void SetPackagesForCountingInteractions( HttpListenerRequest req, HttpListenerResponse res) { Logger.Info(nameof(SetPackagesForCountingInteractions)); try { Dictionary <string, long> dictionary = JObject.Parse(HTTPUtils.ParseRequest(req).Data["data"]).ToDictionary <long>() as Dictionary <string, long>; List <string> stringList = new List <string>(); foreach (KeyValuePair <string, long> packagesCountClick in AppHandler.sAppPackagesCountClicks) { if (!dictionary.ContainsKey(packagesCountClick.Key)) { stringList.Add(packagesCountClick.Key); } } foreach (string key in stringList) { AppHandler.sAppPackagesCountClicks.Remove(key); } foreach (KeyValuePair <string, long> keyValuePair in dictionary) { if (!AppHandler.sAppPackagesCountClicks.ContainsKey(keyValuePair.Key.ToLower())) { AppHandler.sAppPackagesCountClicks.Add(keyValuePair.Key.ToLower(), 0L); } } foreach (KeyValuePair <string, long> packagesCountClick in AppHandler.sAppPackagesCountClicks) { Logger.Info("questpackage: " + packagesCountClick.Key.ToString()); } } catch (Exception ex) { Logger.Error("Exception in Server SetPackagesForCountingInteractions. Err : " + ex.ToString()); HTTPHandler.WriteErrorJson(ex.Message, res); } }
public bool Authorize(ref string message) { string admin_bearer_token = HTTPHandler.GetBearerToken(ref data); if (!string.IsNullOrEmpty(admin_bearer_token)) { if (AdminPanel.CheckAvalibleToken(ref admin_bearer_token, ref message)) { Logger.WriteLog("Admin token was authorize successfully.", LogLevel.Warning); return(true); } else { Logger.WriteLog(message, LogLevel.Warning); return(false); } } else { Logger.WriteLog("Server can't get bearer token from request.", LogLevel.Warning); message = "Server can't get bearer token from request."; return(false); } }
public void ResponseJsonAnswer(bool success, string message) { HTTPHandler.JsonAnswer(success, message, ref remoteSocket); }
public void ResponseJsonUTF8Data(dynamic data) { HTTPHandler.JsonUTF8Data(ref data, ref remoteSocket); }
public string GetBearerToken() { BearerToken = HTTPHandler.GetBearerToken(ref data); return(BearerToken); }
public void handleParametersAndBody(HTTPHandler handler, HTTPRawReader reader) { while (true) { string this_line = reader.readLine(); if ((this_line == null) || (this_line.Length == 0)) { break; } handle_header_line(this_line, handler); } handler.handleHeaderDone(); byte[] buffer = new byte[256]; if (chunked) { while (true) { long chunk_byte_count = 0; while (true) { int num = reader.read_bytes(buffer, 1); if (num < 1) { throw new Exception("Unexpected end of chunk header."); } if (buffer[0] == '\r') { break; } if (buffer[0] == ' ') { continue; } long digit; if ((buffer[0] >= '0') && (buffer[0] <= '9')) { digit = buffer[0] - '0'; } else if ((buffer[0] >= 'a') && (buffer[0] <= 'f')) { digit = (buffer[0] - 'a') + 0xa; } else if ((buffer[0] >= 'A') && (buffer[0] <= 'F')) { digit = (buffer[0] - 'A') + 0xa; } else { throw new Exception("Bad digit in chunk header."); } if (chunk_byte_count >= (Int64.MaxValue - digit) / 16) { throw new Exception("Overflow in chunk header."); } chunk_byte_count = (chunk_byte_count * 16) + digit; } if (chunk_byte_count == 0) { break; } { int num = reader.read_bytes(buffer, 1); if (num < 1) { throw new Exception("Unexpected end of chunk header."); } if (buffer[0] != '\n') { throw new Exception("Bad end-of-line in chunk header."); } } while (chunk_byte_count > 0) { int num = reader.read_bytes(buffer, ((chunk_byte_count > 256) ? 256 : (int)chunk_byte_count)); if (num < 1) { break; } handler.handleContent(num, buffer); chunk_byte_count -= num; } { int num = reader.read_bytes(buffer, 1); if (num < 1) { throw new Exception("Unexpected end of chunk."); } if (buffer[0] != '\r') { throw new Exception("Bad end-of-line in chunk."); } } { int num = reader.read_bytes(buffer, 1); if (num < 1) { throw new Exception("Unexpected end of chunk."); } if (buffer[0] != '\n') { throw new Exception("Bad end-of-line in chunk."); } } } /* @@@ */ /* @@@ -- Read the trailer. */ /* @@@ */ } else if (have_content_length) { while (content_length > 0) { int num = reader.read_bytes(buffer, ((content_length > 256) ? 256 : (int)content_length)); if (num < 1) { break; } Debug.Assert(num <= content_length); handler.handleContent(num, buffer); content_length -= num; } } else { while (true) { int num = reader.read_bytes(buffer, 256); if (num < 1) { break; } handler.handleContent(num, buffer); } } handler.handleContentEnd(); }
void SendRequest(PostRequestsOptions request) { string post = JsonUtility.ToJson(request, true); HTTPHandler.PostRequest(post); }
public static List <MendeleyJSONResult> Search(string Query, MendeleyDataType[] Types = null, int?Page = null) { string URL = $"{MendeleyInnerAPI}?query={Query.URLEncoded()}&page={Page}&{Types.Parse()}"; return(HTTPHandler.GetJSON <MendeleyJSONRootObject>(URL).results); }
/// <summary> /// Gets a collection of nodes from a URL, searching by class name. /// </summary> /// <param name="URL"></param> /// <param name="Classes"></param> /// <returns></returns> public static IEnumerable <HtmlNode> GetNodesFromURLByClass(string URL, params string[] Classes) { string RawHTML = HTTPHandler.GetString(URL); return(HTMLParser.GetNodesByClass(RawHTML, Classes)); }
// Refresh departures when button is pressed public async Task <IActionResult> OnPostAsync() { Departures = await HTTPHandler.UpdateDepartures(); return(Page()); }