Skip to content

Commit

Permalink
Remove Set-PodeResponseStatus when status is 200
Browse files Browse the repository at this point in the history
  • Loading branch information
mdaneri committed Apr 4, 2024
1 parent d54d1ab commit 71149e1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
21 changes: 10 additions & 11 deletions src/Private/Helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1766,22 +1766,21 @@ function Test-PodePath {

}

# if we failed to get the file, report back the status code and/or return true/false
if (!$NoStatus.IsPresent) {
Set-PodeResponseStatus -Code $statusCode
if ($statusCode -eq 200) {
if ($ReturnItem) {
return $item
}
return $true
}

if ($ReturnItem) {
if ($statusCode -eq 200) {
return $item, $statusCode
}
else {
return $null, $statusCode
# if we failed to get the file, report back the status code and/or return true/false
if (!$NoStatus.IsPresent) {
Set-PodeResponseStatus -Code $statusCode
}
return $null
}

return ($statusCode -eq 200)

return $false
}

function Test-PodePathIsFile {
Expand Down
6 changes: 2 additions & 4 deletions src/Private/Responses.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,9 @@ function Write-PodeFileResponseInternal {
)

# Attempt to retrieve information about the path
$pathInfo , $statusCode = Test-PodePath -Path $Path -Force -ReturnItem -FailOnDirectory:(!$FileBrowser) -NoStatus
$pathInfo = Test-PodePath -Path $Path -Force -ReturnItem -FailOnDirectory:(!$FileBrowser)

if (!$pathinfo) {
Set-PodeResponseStatus -Code $statusCode
return
}

Expand Down Expand Up @@ -425,10 +424,9 @@ function Write-PodeAttachmentResponseInternal {
)

# Attempt to retrieve information about the path
$pathInfo , $statusCode = Test-PodePath -Path $Path -Force -ReturnItem -FailOnDirectory:(!$FileBrowser) -NoStatus
$pathInfo = Test-PodePath -Path $Path -Force -ReturnItem -FailOnDirectory:(!$FileBrowser)

if (!$pathinfo) {
Set-PodeResponseStatus -Code $statusCode
return
}

Expand Down

0 comments on commit 71149e1

Please sign in to comment.