Exemplo n.º 1
0
        public void TechEmpowerHelloWorldNoIO(int numberOfRequests, int concurrentConnections)
        {
            RawInMemoryHttpServer.Run(numberOfRequests, concurrentConnections, s_genericRequest, (request, response) => {
                var formatter = new BufferWriterFormatter <PipeWriter>(response, SymbolTable.InvariantUtf8);
                formatter.Append("HTTP/1.1 200 OK");
                formatter.Append("\r\nContent-Length: 13");
                formatter.Append("\r\nContent-Type: text/plain");
                formatter.Format("\r\nDate: {0:R}", DateTime.UtcNow);
                formatter.Append("Server: System.IO.Pipelines");
                formatter.Append("\r\n\r\n");

                // write body
                formatter.Append("Hello, World!");
            });
        }
Exemplo n.º 2
0
        public void TechEmpowerJsonNoIO(int numberOfRequests, int concurrentConnections)
        {
            RawInMemoryHttpServer.Run(numberOfRequests, concurrentConnections, s_genericRequest, (request, response) => {
                var formatter = new BufferWriterFormatter <PipeWriter>(response, SymbolTable.InvariantUtf8);
                formatter.Append("HTTP/1.1 200 OK");
                formatter.Append("\r\nContent-Length: 25");
                formatter.Append("\r\nContent-Type: application/json");
                formatter.Format("\r\nDate: {0:R}", DateTime.UtcNow);
                formatter.Append("Server: System.IO.Pipelines");
                formatter.Append("\r\n\r\n");

                // write body
                var writer = new JsonWriterUtf8(formatter);
                writer.WriteObjectStart();
                writer.WriteAttribute("message", "Hello, World!");
                writer.WriteObjectEnd();
            });
        }