Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions examples/IIS-Example.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
.EXAMPLE
To run the sample: ./IIS-Example.ps1


Invoke-RestMethod -Uri http://localhost:8081 -Method Get

Invoke-RestMethod -Uri http://localhost:8081/run-task -Method Get
Expand Down Expand Up @@ -43,11 +42,13 @@ catch { throw }

# create a server, and start listening on port 8081
Start-PodeServer {

# listen on localhost:8081
# listen on localhost:8081 or HTTP_PLATFORM_PORT for httpPlatformHandler
Add-PodeEndpoint -Address localhost -Port 8081 -Protocol Http
New-PodeLoggingMethod -Terminal | Enable-PodeRequestLogging
New-PodeLoggingMethod -Terminal | Enable-PodeErrorLogging
# Add-PodeEndpoint -Address localhost -Port $env:HTTP_PLATFORM_PORT -Protocol Http

# enable logging to file
New-PodeLoggingMethod -File -Name 'requests' | Enable-PodeRequestLogging
New-PodeLoggingMethod -File -Name 'errors' | Enable-PodeErrorLogging

# Add-PodeLimitAccessRule -Name 'DenyLocal' -Action Deny -Component @(
# New-PodeLimitIPComponent -IP localhost -Location XForwardedFor
Expand Down
39 changes: 37 additions & 2 deletions examples/web.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<configuration>
<?xml version="1.0" encoding="UTF-8"?>
<!-- ASP.NET CORE CONFIG -->
<!-- <configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<remove name="WebDAV" />
<remove name="httpPlatformHandler" />
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
Expand All @@ -14,7 +17,12 @@
<remove name="WebDAVModule" />
</modules>

<aspNetCore processPath="pwsh.exe" arguments=".\IIS-Example.ps1" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess"/>
<aspNetCore
processPath="C:\tools\pwsh\pwsh.exe"
arguments=".\IIS-Example.ps1"
stdoutLogEnabled="true"
stdoutLogFile=".\logs\stdout"
hostingModel="OutOfProcess" />

<security>
<authorization>
Expand All @@ -24,4 +32,31 @@
</security>
</system.webServer>
</location>
</configuration> -->

<!-- HTTP_PLATFORM_HANDLER CONFIG -->
<configuration>
<system.webServer>
<handlers>
<remove name="WebDAV" />
<remove name="aspNetCore" />
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>

<httpPlatform
processPath="C:\tools\pwsh\pwsh.exe"
arguments="-NoProfile -ExecutionPolicy Bypass -File &quot;.\IIS-Example.ps1&quot;"
forwardWindowsAuthToken="false"
stdoutLogEnabled="true"
stdoutLogFile=".\logs\stdout"
startupTimeLimit="60" >

<environmentVariables>
<environmentVariable name="PODE_HOST" value="IIS" />
</environmentVariables>

</httpPlatform>

<httpErrors existingResponse="PassThrough" />
</system.webServer>
</configuration>
23 changes: 11 additions & 12 deletions src/Listener/Protocols/Common/Requests/PodeRequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,6 @@ public async Task<bool> Receive(CancellationToken cancellationToken)
{
PodeHelpers.WriteException(ex, Context.Listener, PodeLoggingLevel.Verbose);
}
catch (IOException ex)
{
if (Context.Listener.IsConnected)
{
PodeHelpers.WriteException(ex, Context.Listener, PodeLoggingLevel.Debug);
}
}
catch (ObjectDisposedException ex)
{
if (Context.Listener.IsConnected)
Expand All @@ -316,26 +309,32 @@ public async Task<bool> Receive(CancellationToken cancellationToken)
{
if (Context.Listener.IsConnected)
{
PodeHelpers.WriteException(ex, Context.Listener, PodeLoggingLevel.Error);
Error = Strategy.CreateException(ex, PodeRequestStatusType.ServerError);
}
}
catch (PodeRequestException ex)
{
PodeHelpers.WriteException(ex, Context.Listener, PodeLoggingLevel.Error);
Error = ex;
}
catch (Exception ex) when (ex is IOException || ex is ObjectDisposedException)
{
// let the calling method handle these exceptions
throw;
}
catch (Exception ex)
{
PodeHelpers.WriteException(ex, Context.Listener, PodeLoggingLevel.Error);
Error = Strategy.CreateException(ex, PodeRequestStatusType.ServerError);
// unexpected exception, log and return a generic error response
if (Context.Listener.IsConnected)
{
Error = Strategy.CreateException(ex, PodeRequestStatusType.ServerError);
}
}
finally
{
PartialDispose();
}

return false;
return true;
}

/// <summary>
Expand Down
Loading