mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 06:48:31 +00:00
Add state assertions to redbean Lua APIs
Many of the API functions provided by redbean are only appropriate to call in certain contexts, such as request handling or .init.lua, etc. For example, Fetch can't be called from the global scope of .init.lua because SSL hasn't been configured yet. Earlier if this happened then redbean would crash, which was confusing. What we'll do now is show a friendly error message. See #97 This change also undocuments redbean ssl compression support since it seems to be causing a flake in the testing infrastructure.
This commit is contained in:
parent
3bfb7580c5
commit
ee7e296339
7 changed files with 165 additions and 37 deletions
|
@ -1,3 +1,12 @@
|
|||
SetStatus(200)
|
||||
SetHeader("Content-Type", GetHeader("Content-Type") or "text/plain")
|
||||
Write(GetPayload())
|
||||
local function main()
|
||||
if GetMethod() ~= 'POST' and GetMethod() ~= 'PUT' then
|
||||
ServeError(405)
|
||||
SetHeader('Allow', 'POST, PUT')
|
||||
return
|
||||
end
|
||||
SetStatus(200)
|
||||
SetHeader("Content-Type", GetHeader("Content-Type") or "text/plain")
|
||||
Write(GetPayload())
|
||||
end
|
||||
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue