Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mdaneri committed Nov 30, 2024
1 parent c7490f8 commit 0e4cc8b
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 61 deletions.
39 changes: 39 additions & 0 deletions examples/Web-SelfSigned.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<#
.SYNOPSIS
A sample PowerShell script to set up a HTTPS Pode server with a self-sign certificate
.DESCRIPTION
This script sets up a Pode server listening on port 8081 in HTTPS
.EXAMPLE
To run the sample: ./Web-SelfSigned.ps1
.LINK
https://github.com/Badgerati/Pode/blob/develop/examples/Web-SelfSigned.ps1
.NOTES
Author: Pode Team
License: MIT License
#>
try {
$ScriptPath = (Split-Path -Parent -Path $MyInvocation.MyCommand.Path)
$podePath = Split-Path -Parent -Path $ScriptPath
if (Test-Path -Path "$($podePath)/src/Pode.psm1" -PathType Leaf) {
Import-Module "$($podePath)/src/Pode.psm1" -Force -ErrorAction Stop
}
else {
Import-Module -Name 'Pode' -MaximumVersion 2.99 -ErrorAction Stop
}
}
catch { throw }

Start-PodeServer -Threads 6 {
Add-PodeEndpoint -Address localhost -Port '8081' -Protocol 'Https' -SelfSigned

New-PodeLoggingMethod -File -Name 'requests' | Enable-PodeRequestLogging
New-PodeLoggingMethod -File -Name 'errors' | Enable-PodeErrorLogging

Add-PodeRoute -Method Get -Path / -ScriptBlock {
Write-PodeTextResponse -Value 'Test'
}
}
18 changes: 0 additions & 18 deletions src/Listener/PodeHttpRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -412,24 +412,6 @@ public override void PartialDispose()
base.PartialDispose();
}

/* public override void Dispose()
{
RawBody = default;
_body = string.Empty;
if (BodyStream != default(MemoryStream))
{
BodyStream.Dispose();
}
if (Form != default(PodeForm))
{
Form.Dispose();
}
base.Dispose();
}*/

/// <summary>
/// Dispose managed and unmanaged resources.
/// </summary>
Expand Down
14 changes: 0 additions & 14 deletions src/Listener/PodeSignalRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,6 @@ protected override async Task<bool> Parse(byte[] bytes, CancellationToken cancel
return true;
}

/* public override void Dispose()
{
// send close frame
if (!IsDisposed)
{
PodeHelpers.WriteErrorMessage($"Closing Websocket", Context.Listener, PodeLoggingLevel.Verbose, Context);
Context.Response.WriteFrame(string.Empty, PodeWsOpCode.Close).Wait();
}
// remove client, and dispose
Context.Listener.Signals.Remove(Signal.ClientId);
base.Dispose();
}*/

/// <summary>
/// Dispose managed and unmanaged resources.
/// </summary>
Expand Down
28 changes: 6 additions & 22 deletions src/Listener/PodeSmtpRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public PodeSmtpRequest(Socket socket, PodeSocket podeSocket, PodeContext context
Type = PodeProtocolType.Smtp;
}

private bool IsCommand(string content, string command)
private static bool IsCommand(string content, string command)
{
if (string.IsNullOrWhiteSpace(content))
{
Expand Down Expand Up @@ -291,7 +291,7 @@ public void Reset()
Attachments = new List<PodeSmtpAttachment>();
}

private string ParseEmail(string value)
private static string ParseEmail(string value)
{
var parts = value.Split(':');
if (parts.Length > 1)
Expand Down Expand Up @@ -364,7 +364,7 @@ private Hashtable ParseHeaders(string value)
return headers;
}

private bool IsBodyValid(string value)
private static bool IsBodyValid(string value)
{
var lines = value.Split(new string[] { PodeHelpers.NEW_LINE }, StringSplitOptions.None);
return Array.LastIndexOf(lines, ".") > -1;
Expand Down Expand Up @@ -423,7 +423,7 @@ private void ParseBoundary()
}
}

private string ParseBody(string value, string boundary = null)
private static string ParseBody(string value, string boundary = null)
{
// split the message up
var lines = value.Split(new string[] { PodeHelpers.NEW_LINE }, StringSplitOptions.None);
Expand Down Expand Up @@ -455,7 +455,7 @@ private string ParseBody(string value, string boundary = null)
return body;
}

private byte[] ConvertBodyEncoding(string body, string contentEncoding)
private static byte[] ConvertBodyEncoding(string body, string contentEncoding)
{
switch (contentEncoding.ToLowerInvariant())
{
Expand All @@ -476,7 +476,7 @@ private byte[] ConvertBodyEncoding(string body, string contentEncoding)
}
}

private string ConvertBodyType(byte[] bytes, string contentType)
private static string ConvertBodyType(byte[] bytes, string contentType)
{
if (bytes == default(byte[]) || bytes.Length == 0)
{
Expand Down Expand Up @@ -516,22 +516,6 @@ private string ConvertBodyType(byte[] bytes, string contentType)
}
}

/* public override void Dispose()
{
RawBody = default;
Body = string.Empty;
if (Attachments != default(List<PodeSmtpAttachment>))
{
foreach (var attachment in Attachments)
{
attachment.Dispose();
}
}
base.Dispose();
}*/

/// <summary>
/// Dispose managed and unmanaged resources.
/// </summary>
Expand Down
7 changes: 0 additions & 7 deletions src/Listener/PodeTcpRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@ public void Close()
Context.Dispose(true);
}

/* public override void Dispose()
{
RawBody = default;
_body = string.Empty;
base.Dispose();
}*/

/// <summary>
/// Dispose managed and unmanaged resources.
/// </summary>
Expand Down

0 comments on commit 0e4cc8b

Please sign in to comment.