mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Do some work on redbean
- Rewrite Slurp() API to be like string.sub() - Introduce a new Barf() API for creating files - Update Redbean `-S` sandbox flag to do unveiling
This commit is contained in:
parent
742251dd92
commit
48ce3ad7cc
9 changed files with 296 additions and 33 deletions
|
@ -39,24 +39,32 @@ local function main()
|
|||
WriteForm("https://www.cloudflare.com/robots.txt")
|
||||
elseif GetMethod() == 'POST' then
|
||||
status, headers, payload = Fetch(GetParam('url'))
|
||||
WriteForm(GetParam('url'))
|
||||
Write('<dl>\r\n')
|
||||
Write('<dt>Status\r\n')
|
||||
Write('<dd><p>%d %s\r\n' % {status, GetHttpReason(status)})
|
||||
Write('<dt>Headers\r\n')
|
||||
Write('<dd>\r\n')
|
||||
for k,v in pairs(headers) do
|
||||
Write('<div class="hdr"><strong>')
|
||||
Write(EscapeHtml(k))
|
||||
Write('</strong>: ')
|
||||
Write(EscapeHtml(v))
|
||||
Write('</div>\r\n')
|
||||
if status then
|
||||
WriteForm(GetParam('url'))
|
||||
Write('<dl>\r\n')
|
||||
Write('<dt>Status\r\n')
|
||||
Write('<dd><p>%d %s\r\n' % {status, GetHttpReason(status)})
|
||||
Write('<dt>Headers\r\n')
|
||||
Write('<dd>\r\n')
|
||||
for k,v in pairs(headers) do
|
||||
Write('<div class="hdr"><strong>')
|
||||
Write(EscapeHtml(k))
|
||||
Write('</strong>: ')
|
||||
Write(EscapeHtml(v))
|
||||
Write('</div>\r\n')
|
||||
end
|
||||
Write('<dt>Payload\r\n')
|
||||
Write('<dd><pre>')
|
||||
Write(EscapeHtml(VisualizeControlCodes(payload)))
|
||||
Write('</pre>\r\n')
|
||||
Write('</dl>\r\n')
|
||||
else
|
||||
err = headers
|
||||
WriteForm(GetParam('url'))
|
||||
Write('<h3>Error</h3>\n')
|
||||
Write('<p>')
|
||||
Write(EscapeHtml(VisualizeControlCodes(err)))
|
||||
end
|
||||
Write('<dt>Payload\r\n')
|
||||
Write('<dd><pre>')
|
||||
Write(EscapeHtml(VisualizeControlCodes(payload)))
|
||||
Write('</pre>\r\n')
|
||||
Write('</dl>\r\n')
|
||||
else
|
||||
ServeError(405)
|
||||
SetHeader('Allow', 'GET, HEAD, POST')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue