Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into service
Browse files Browse the repository at this point in the history
  • Loading branch information
mdaneri committed Feb 22, 2025
2 parents c559b8e + cbdc62f commit 30e7223
Show file tree
Hide file tree
Showing 6 changed files with 243 additions and 112 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'
}
}
33 changes: 23 additions & 10 deletions src/Listener/PodeHttpRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -412,22 +412,35 @@ public override void PartialDispose()
base.PartialDispose();
}

public override void Dispose()
/// <summary>
/// Dispose managed and unmanaged resources.
/// </summary>
/// <param name="disposing">Indicates whether the method is called explicitly or by garbage collection.</param>
protected override void Dispose(bool disposing)
{
RawBody = default;
_body = string.Empty;
if (IsDisposed) return;

if (BodyStream != default(MemoryStream))
if (disposing)
{
BodyStream.Dispose();
}
// Custom cleanup logic for PodeHttpRequest
RawBody = default;
_body = string.Empty;

if (Form != default(PodeForm))
{
Form.Dispose();
if (BodyStream != default(MemoryStream))
{
BodyStream.Dispose();
BodyStream = default;
}

if (Form != default(PodeForm))
{
Form.Dispose();
Form = default;
}
}

base.Dispose();
// Call the base Dispose to clean up shared resources
base.Dispose(disposing);
}
}
}
Loading

0 comments on commit 30e7223

Please sign in to comment.