CreateResponseHeader() public static method

public static CreateResponseHeader ( HttpStatusCode code ) : string
code HttpStatusCode
return string
Ejemplo n.º 1
0
        protected override async Task DoProcess(CancellationToken cancellationToken)
        {
            this.state = ConnectionState.Waiting;
            try {
                if (connection != null && !IsStopped)
                {
                    await Handshake(cancellationToken).ConfigureAwait(false);
                    await ReadContents(cancellationToken).ConfigureAwait(false);
                }
                this.state = ConnectionState.Closed;
            }
            catch (HTTPError e) {
                await connection.Stream.WriteUTF8Async(HTTPUtils.CreateResponseHeader(e.StatusCode)).ConfigureAwait(false);

                Stop(StopReason.BadAgentError);
                this.state = ConnectionState.Error;
            }
            catch (IOException e) {
                Logger.Error(e);
                Stop(StopReason.ConnectionError);
                this.state = ConnectionState.Error;
            }
            catch (ConnectionStoppedExcception) {
                this.state = ConnectionState.Closed;
            }
        }
Ejemplo n.º 2
0
        private async Task SendErrorResponse(HttpStatusCode code)
        {
            var response_header = HTTPUtils.CreateResponseHeader(code, new Dictionary <string, string>());
            await Connection.WriteAsync(System.Text.Encoding.UTF8.GetBytes(response_header)).ConfigureAwait(false);

            Logger.Debug("Header: {0}", response_header);
        }