private async void HandleRequest(StreamSocket socket)
        {
            var reader = new DataReader(socket.InputStream)
            {
                InputStreamOptions = InputStreamOptions.Partial
            };
            var writer = new DataWriter(socket.OutputStream)
            {
                UnicodeEncoding = UnicodeEncoding.Utf8
            };

            var acceptedRequest = new AcceptedRequest();
            await acceptedRequest.AcceptRequest(reader);

            string response;

            try
            {
                response = HttpResponseHelper.ResponseString(
                    HttpStatusCode.OK,
                    this.automator.ProcessCommand(acceptedRequest.Content));
            }
            catch (NotImplementedException exception)
            {
                response = HttpResponseHelper.ResponseString(HttpStatusCode.NotImplemented, exception.Message);
            }
            catch (Exception exception)
            {
                response = HttpResponseHelper.ResponseString(HttpStatusCode.InternalServerError, exception.Message);
            }

            writer.WriteString(response);
            await writer.StoreAsync();

            socket.Dispose();

            if (this.automator.DoAfterResponseOnce == null)
            {
                return;
            }

            var localDoAfterResponseOnce = this.automator.DoAfterResponseOnce;

            this.automator.DoAfterResponseOnce = null;

            localDoAfterResponseOnce();
        }
        private async void HandleRequest(StreamSocket socket)
        {
            var reader = new DataReader(socket.InputStream) { InputStreamOptions = InputStreamOptions.Partial };
            var writer = new DataWriter(socket.OutputStream) { UnicodeEncoding = UnicodeEncoding.Utf8 };

            var acceptedRequest = new AcceptedRequest();
            await acceptedRequest.AcceptRequest(reader);

            string response;
            try
            {
                response = HttpResponseHelper.ResponseString(
                    HttpStatusCode.OK, 
                    this.automator.ProcessCommand(acceptedRequest.Content));
            }
            catch (NotImplementedException ex)
            {
                response = HttpResponseHelper.ResponseString(HttpStatusCode.NotImplemented, ex.Message);
            }

            writer.WriteString(response);
            await writer.StoreAsync();

            socket.Dispose();

            if (this.automator.DoAfterResponseOnce == null)
            {
                return;
            }

            var localDoAfterResponseOnce = this.automator.DoAfterResponseOnce;
            this.automator.DoAfterResponseOnce = null;

            localDoAfterResponseOnce();
        }