emptygif
语言: 简体中文

所有语言和框架

Pode PowerShell

一个用于 Pode 的 PowerShell 代码片段,以空 GIF 响应对 /pixel.gif 的请求,GIF 在启动时只解码一次。

Pode PowerShell

安装
Install-Module -Name Pode
文件
server.ps1
运行
pwsh ./server.ps1
Import-Module Pode

Start-PodeServer {
    Add-PodeEndpoint -Address * -Port 8080 -Protocol Http
    Set-PodeState -Name 'Gif' -Value ([Convert]::FromBase64String('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==')) | Out-Null

    Add-PodeRoute -Method Get -Path '/pixel.gif' -ScriptBlock {
        Set-PodeHeader -Name 'Cache-Control' -Value 'no-store'
        # Pode appends '; charset=utf-8' to the type; browsers ignore it for images.
        Write-PodeTextResponse -Bytes (Get-PodeState -Name 'Gif') -ContentType 'image/gif'
    }
}

我们运行了此代码片段,并比对了它返回的字节。

验证

curl -sI http://localhost:8080/pixel.gif

官方网站: Pode

更多 PowerShell 示例