/*
* Copyright (c) 2023 Vaughn Nugent
*
* Library: VNLib
* Package: VNLib.Net.Http
* File: IConnectionInfo.cs
*
* IConnectionInfo.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.Net;
using System.Text;
using System.Collections.Generic;
namespace VNLib.Net.Http
{
///
/// Represents a client's connection info as interpreted by the current server
///
/// Methods and properties are undefined when returns
public interface IConnectionInfo
{
///
/// Full request uri of current connection
///
Uri RequestUri { get; }
///
/// Current request path. Shortcut to
///
string Path => RequestUri.LocalPath;
///
/// Current connection's user-agent header, (may be null if no user-agent header found)
///
string? UserAgent { get; }
///
/// Current connection's headers
///
IHeaderCollection Headers { get; }
///
/// A value that indicates if the connection's origin header was set and it's
/// authority segment does not match the authority
/// segment.
///
bool CrossOrigin { get; }
///
/// Is the current connecion a websocket request
///
bool IsWebSocketRequest { get; }
///
/// Request specified content-type
///
ContentType ContentType { get; }
///
/// Current request's method
///
HttpMethod Method { get; }
///
/// The current connection's HTTP protocol version
///
HttpVersion ProtocolVersion { get; }
///
/// Origin header of current connection if specified, null otherwise
///
Uri? Origin { get; }
///
/// Referer header of current connection if specified, null otherwise
///
Uri? Referer { get; }
///
/// The parsed range header, check the
/// to determine if the range has been set
///
HttpRange Range { get; }
///
/// The server endpoint that accepted the connection
///
IPEndPoint LocalEndpoint { get; }
///
/// The raw of the downstream connection.
///
IPEndPoint RemoteEndpoint { get; }
///
/// The encoding type used to decode and encode character data to and from the current client
///
Encoding Encoding { get; }
///
/// A of client request cookies
///
IReadOnlyDictionary RequestCookies { get; }
///
/// Gets an for the parsed accept header values
///
IReadOnlyCollection Accept { get; }
///
/// Gets the underlying transport security information for the current connection
///
ref readonly TransportSecurityInfo? GetTransportSecurityInfo();
///
/// Adds a new cookie to the response. If a cookie with the same name and value
/// has been set, the old cookie is replaced with the new one.
///
/// A reference to the cookie to set on the current response
void SetCookie(in HttpResponseCookie cookie);
}
}