-
-
Notifications
You must be signed in to change notification settings - Fork 100
Open
Labels
Description
Describe the Bug
When performing a HEAD request against a static file (likely a dynamically generated one too), Pode will read the entire contents of the file first, and then reply with the status code. The larger the file, the longer the response will take.
In my use case, the client will perform a HEAD request for every file first, and then a GET request for those files, which can take much longer than necessary as the file list is about a hundred files going up to a couple of hundred of megabytes.
Steps To Reproduce
Steps to reproduce the behavior:
- Create a new Pode project with the following
server.ps1Start-PodeServer -ScriptBlock { New-PodeLoggingMethod -Terminal | Enable-PodeRequestLogging Add-PodeEndpoint -Address 127.0.0.1 -Port 8080 -Protocol Http 'Creating files...' | Out-PodeHost 1..100 | ForEach-Object { New-Item -Path ".\public\$_.txt" -Force $fileSize = 1MB $randomBytes = New-Object byte[] $fileSize (New-Object System.Random).NextBytes($randomBytes) [System.IO.File]::WriteAllBytes(".\public\$_.txt", $randomBytes) } }
- Start the Pode server, and in another PowerShell instance, run
Measure-Command { 1..100 | %{ Invoke-WebRequest -Method Head -Uri "http://127.0.0.1:8080/$_.txt" }}
- It will be nearly instantaneous.
- Modify the
$fileSizevariable to 100MB and rerun the server and test - It will take about 15 seconds (depending on the processor)
Platform
- OS: Windows
- Browser: Chrome
- Versions:
- Pode: 2.12.1
- PowerShell: 7.5.2
Metadata
Metadata
Assignees
Labels
Projects
Status
Backlog