/*
* Copyright (c) 2024 Vaughn Nugent
*
* Library: VNLib
* Package: VNLib.Net.Http
* File: IHttpEvent.cs
*
* IHttpEvent.cs is part of VNLib.Net.Http which is part of the larger
* VNLib collection of libraries and utilities.
*
* VNLib.Net.Http is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* VNLib.Net.Http is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
using System;
using System.IO;
using System.Net;
using System.Collections.Generic;
namespace VNLib.Net.Http
{
///
/// Contains an http request and session information.
///
public interface IHttpEvent
{
///
/// Current connection information. (Like "$_SERVER" superglobal in PHP)
///
IConnectionInfo Server { get; }
///
/// The that this connection originated from
///
IHttpServer OriginServer { get; }
///
/// If the request has query arguments they are stored in key value format
///
/// Keys are case-insensitive
IReadOnlyDictionary QueryArgs { get; }
///
/// If the request body has form data or url encoded arguments they are stored in key value format
///
IReadOnlyDictionary RequestArgs { get; }
///
/// Contains all files upladed with current request
///
/// Keys are case-insensitive
IReadOnlyList Files { get; }
///
/// Complete the session and respond to user
///
/// Status code of operation
///
void CloseResponse(HttpStatusCode code);
///
/// Responds to a client with a containing data to be sent to user of a given contentType.
/// Runtime will dispose of the stream during closing event
///
/// Response status code
/// MIME ContentType of data
/// Data to be sent to client
/// Length of data to read from the stream and send to client
///
///
///
///
void CloseResponse(HttpStatusCode code, ContentType type, Stream stream, long length);
///
/// Responds to a client with an in-memory containing data
/// to be sent to user of a given contentType.
///
/// The status code to set
/// The entity content-type
/// The in-memory response data
///
///
void CloseResponse(HttpStatusCode code, ContentType type, IMemoryResponseReader entity);
///
/// Responds to a client with an containing data to be sent
/// to user of a given contentType.
///
/// The http status code
/// The entity content type
/// The entity body to stream to the client
/// The length in bytes of the stream data
///
///
void CloseResponse(HttpStatusCode code, ContentType type, IHttpStreamResponse entity, long length);
///
/// Configures the server to change protocols from HTTP to the specified
/// custom protocol handler.
///
/// The custom protocol handler
///
///
void DangerousChangeProtocol(IAlternateProtocol protocolHandler);
///
/// Sets an http server control mask to be applied to the current event flow
///
void SetControlFlag(ulong mask);
}
}