using System; using System.Collections.Generic; namespace Crestron.SimplSharp.Net.Http { /// HTTP request types public enum RequestType { /// GET request Get = 0, /// POST request Post = 1, /// PUT request Put = 2, /// DELETE request Delete = 3, /// HEAD request Head = 4, /// OPTIONS request Options = 5, /// PATCH request Patch = 6 } /// Mock HTTP client public class HttpClient { /// Gets or sets the keep-alive setting public bool KeepAlive { get; set; } = false; /// Gets or sets the port number public int Port { get; set; } = 80; /// Dispatch HTTP request /// HTTP request /// Callback for response public void Dispatch(HttpClientRequest request, Action callback) { // Mock implementation - invoke callback with empty response var response = new HttpClientResponse(); callback?.Invoke(response); } /// Dispatches HTTP request synchronously /// HTTP request /// HTTP response public HttpClientResponse Dispatch(HttpClientRequest request) { // Mock implementation - return empty response return new HttpClientResponse(); } } /// Mock HTTP client request public class HttpClientRequest { /// Gets or sets the URL parser public Crestron.SimplSharp.Net.Http.UrlParserResult Url { get; set; } = new Crestron.SimplSharp.Net.Http.UrlParserResult(); /// Gets or sets the HTTP method public RequestType RequestType { get; set; } = RequestType.Get; /// Gets or sets the content data public string ContentString { get; set; } = string.Empty; /// Gets the headers collection public HttpHeaderCollection Header { get; } = new HttpHeaderCollection(); } /// Mock HTTP client response public class HttpClientResponse { /// Gets the response code public int Code { get; set; } = 200; /// Gets the response content public string ContentString { get; set; } = string.Empty; /// Gets the response data as bytes public byte[] ContentBytes { get; set; } = Array.Empty(); /// Gets the headers collection public HttpHeaderCollection Header { get; } = new HttpHeaderCollection(); } /// Mock HTTP header collection public class HttpHeaderCollection { private readonly Dictionary _headers = new Dictionary(); /// Gets or sets the content type public string ContentType { get => _headers.TryGetValue("Content-Type", out var value) ? value : string.Empty; set => _headers["Content-Type"] = value; } /// Sets a header value /// Header name /// Header value public void SetHeaderValue(string name, string value) { _headers[name] = value; } /// Gets a header value /// Header name /// Header value or empty string if not found public string GetHeaderValue(string name) { return _headers.TryGetValue(name, out var value) ? value : string.Empty; } } } namespace Crestron.SimplSharp.Net.Https { /// HTTPS request types public enum RequestType { /// GET request Get = 0, /// POST request Post = 1, /// PUT request Put = 2, /// DELETE request Delete = 3, /// HEAD request Head = 4, /// OPTIONS request Options = 5, /// PATCH request Patch = 6 } /// Mock HTTPS client public class HttpsClient { /// Gets or sets the keep-alive setting public bool KeepAlive { get; set; } = false; /// Gets or sets the host verification setting public bool HostVerification { get; set; } = false; /// Gets or sets the peer verification setting public bool PeerVerification { get; set; } = false; /// Dispatch HTTPS request /// HTTPS request /// Callback for response public void Dispatch(HttpsClientRequest request, Action callback) { // Mock implementation - invoke callback with empty response var response = new HttpsClientResponse(); callback?.Invoke(response); } /// Dispatches HTTPS request synchronously /// HTTPS request /// HTTPS response public HttpsClientResponse Dispatch(HttpsClientRequest request) { // Mock implementation - return empty response return new HttpsClientResponse(); } } /// Mock HTTPS client request public class HttpsClientRequest { /// Gets or sets the URL parser public Crestron.SimplSharp.Net.Https.UrlParserResult Url { get; set; } = new Crestron.SimplSharp.Net.Https.UrlParserResult(); /// Gets or sets the HTTP method public RequestType RequestType { get; set; } = RequestType.Get; /// Gets or sets the content data public string ContentString { get; set; } = string.Empty; /// Gets the headers collection public HttpsHeaderCollection Header { get; } = new HttpsHeaderCollection(); } /// Mock HTTPS client response public class HttpsClientResponse { /// Gets the response code public int Code { get; set; } = 200; /// Gets the response content public string ContentString { get; set; } = string.Empty; /// Gets the response data as bytes public byte[] ContentBytes { get; set; } = Array.Empty(); /// Gets the headers collection public HttpsHeaderCollection Header { get; } = new HttpsHeaderCollection(); } /// Mock HTTPS header collection public class HttpsHeaderCollection { private readonly Dictionary _headers = new Dictionary(); /// Gets or sets the content type public string ContentType { get => _headers.TryGetValue("Content-Type", out var value) ? value : string.Empty; set => _headers["Content-Type"] = value; } /// Sets a header value /// Header name /// Header value public void SetHeaderValue(string name, string value) { _headers[name] = value; } /// Adds a header /// Header to add public void AddHeader(HttpsHeader header) { _headers[header.Name] = header.Value; } /// Gets a header value /// Header name /// Header value or empty string if not found public string GetHeaderValue(string name) { return _headers.TryGetValue(name, out var value) ? value : string.Empty; } } /// Mock HTTPS header public class HttpsHeader { /// Gets the header name public string Name { get; private set; } /// Gets the header value public string Value { get; private set; } /// Initializes a new instance of HttpsHeader /// Header name /// Header value public HttpsHeader(string name, string value) { Name = name ?? string.Empty; Value = value ?? string.Empty; } } /// Mock HTTP exception public class HttpException : Exception { /// Gets the HTTP response public HttpsClientResponse Response { get; } /// Initializes a new instance of HttpException public HttpException() : base() { Response = new HttpsClientResponse(); } /// Initializes a new instance of HttpException /// Exception message public HttpException(string message) : base(message) { Response = new HttpsClientResponse(); } /// Initializes a new instance of HttpException /// Exception message /// Inner exception public HttpException(string message, Exception innerException) : base(message, innerException) { Response = new HttpsClientResponse(); } /// Initializes a new instance of HttpException /// Exception message /// HTTP response public HttpException(string message, HttpsClientResponse response) : base(message) { Response = response ?? new HttpsClientResponse(); } } }