CC-2925: Airtime scripts broken with Liquidsoap 1.0 pre-release
-fixed -also updated the liquidsoap library scripts
This commit is contained in:
parent
ed8cdc7db3
commit
b0f6f1e39b
30 changed files with 417 additions and 674 deletions
43
python_apps/pypo/liquidsoap_scripts/library/http.liq
Normal file
43
python_apps/pypo/liquidsoap_scripts/library/http.liq
Normal file
|
@ -0,0 +1,43 @@
|
|||
# Set of HTTP utils.
|
||||
|
||||
%include "http_codes.liq"
|
||||
|
||||
# Create a HTTP response string
|
||||
# @category Interaction
|
||||
# @param ~protocol HTTP protocol used.
|
||||
# @param ~code Response code.
|
||||
# @param ~headers Response headers.
|
||||
# @param ~data Response data
|
||||
def http_response(~protocol="HTTP/1.1",
|
||||
~code=200,
|
||||
~headers=[],
|
||||
~data="") =
|
||||
status = http_codes[string_of(code)]
|
||||
# Set content-length if needed and not set by the
|
||||
# user.
|
||||
headers =
|
||||
if data != "" and
|
||||
not list.mem_assoc("Content-Length",headers)
|
||||
then
|
||||
list.append([("Content-Length",
|
||||
"#{string.length(data)}")],
|
||||
headers)
|
||||
else
|
||||
headers
|
||||
end
|
||||
headers = list.map(fun (x) -> "#{fst(x)}: #{snd(x)}",headers)
|
||||
headers = string.concat(separator="\r\n",headers)
|
||||
# If no headers are provided, we should avoid
|
||||
# having an empty line for them. Therefore, we also
|
||||
# conditionally add the final \r\n here.
|
||||
headers =
|
||||
if headers != "" then
|
||||
"#{headers}\r\n"
|
||||
else
|
||||
headers
|
||||
end
|
||||
"#{protocol} #{code} #{status}\r\n\
|
||||
#{headers}\
|
||||
\r\n\
|
||||
#{data}"
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue