public Function(ILogger <Function> logger) { _logger = logger; var configReader = new ConfigReader(logger); _requestReader = new HttpRequestReader(logger); }
public static void LogRequest(this Log log, HttpRequest request) { if (log.IsVerbose) { log.LogMessage(Log.Level.Verbose, "\tMethod: {0}", request.RequestLine.Method); log.LogMessage(Log.Level.Verbose, "\tRequest-URI: {0}", request.RequestLine.RequestUri.ToString()); log.LogMessage(Log.Level.Verbose, "\tHTTP-Version: {0}", request.RequestLine.Version); log.LogMessage(Log.Level.Verbose, "\tHttp Headers:"); foreach (var httpHeader in request.Headers) { log.LogMessage(Log.Level.Verbose, "\t\tName: {0}, Value: {1}", httpHeader.Key, httpHeader.Value); } HttpRequestReader reader = new HttpRequestReader(); reader.Buffer = request.Body; while (true) { var header = reader.ReadHeader(); if (header.Length == 0) { break; } log.LogMessage(Log.Level.Verbose, "\tHeader: {0}", header.ToString()); } var messageBody = reader.Buffer; log.LogMessage(Log.Level.Verbose, "\tBody bytecount: {0}", messageBody.Length); } }
public Function(ILogger <Function> logger) { _logger = logger; var configReader = new ConfigReader(logger); _outputBucket = configReader.Read("BUCKET"); _requestReader = new HttpRequestReader(logger); }
public Function(ILogger <Function> logger) { _logger = logger; var configReader = new ConfigReader(logger); _outputBucket = configReader.Read("BUCKET"); _requestReader = new HttpRequestReader(logger); var fontCollection = new FontCollection(); fontCollection.Install("Arial.ttf"); _font = fontCollection.CreateFont("Arial", 10); }
public void HttpRequestReader_ParseWithContentLength() { var buffer = new MemoryStream(Encoding.UTF8.GetBytes(GetRequestTextWithContentLength())) { Position = 0 }; var parser = new HttpRequestReader(buffer); var request = parser.TryReadAsync().Result; Assert.IsTrue(request != null, "Parse failed."); Assert.AreEqual("Body123{}%!(:<>=", Encoding.UTF8.GetString(request.Body)); }
public void HttpRequestReader_ParseWithoutContentLength() { var buffer = new MemoryStream(Encoding.UTF8.GetBytes(GetRequestTextWithoutContentLength())) { Position = 0 }; var parser = new HttpRequestReader(buffer); var request = parser.TryReadAsync().Result; Assert.IsTrue(request != null, "Parse failed."); Assert.AreEqual(HttpMethod.Delete, request.Method); Assert.AreEqual("/Uri%20/lalalo323/_/-/+/%/@/&/./~/:/#/;/,/*", request.Uri); Assert.AreEqual("Body123{}%!(:<>=", Encoding.UTF8.GetString(request.Body)); Assert.AreEqual(new Version(1, 1), request.HttpVersion); Assert.AreEqual("localhost:2400", request.Headers["Host"]); Assert.AreEqual("keep-alive", request.Headers["Connection"]); Assert.AreEqual("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", request.Headers["Accept"]); Assert.AreEqual("1", request.Headers["Upgrade-Insecure-Requests"]); Assert.AreEqual("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36", request.Headers["User-Agent"]); Assert.AreEqual("gzip, deflate, sdch", request.Headers["Accept-Encoding"]); Assert.AreEqual("de,en-US;q=0.8,en;q=0.6,de-DE;q=0.4", request.Headers["Accept-Language"]); }