Skip to content

Keep an API response's body verbatim - #17

Closed
henrikbjorn wants to merge 1 commit into
masterfrom
raw-api-response
Closed

henrikbjorn wants to merge 1 commit into
masterfrom
raw-api-response

Conversation

@henrikbjorn

@henrikbjorn henrikbjorn commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

An api/response body is the command's output, not headers. Response parsed it as key-value lines whenever it contained a colon, which mangled any such output. For example, global_getvar hold_music returning local_stream://latin came back as {local_stream: "//latin", body: ""}.

The content of an api/response is now the raw body string. Events and command replies are parsed as before. Error handling is unchanged: an API error is still a -ERR … body, not a raised error.

Behaviour change

The Content-Type decides, as the ESL protocol defines it: text/event-plain and command/reply carry headers and are still parsed; an api/response carries opaque command output. Guessing from the content ("does it look like key-value lines?") would still misparse output such as uuid_dump, or a variable whose value happens to be Status: ok.

What changes for callers:

  • Output without a colon (uuid_exists → "true", create_uuid → a uuid): unchanged. It was already a raw String.
  • Output with a colon: a String instead of a lossy Hash, whose keys were lowercased, stripped and URL-decoded.
  • One known caller relied on that Hash. switch/freeswitch/scripts/switch_api.rb#callback_request_exists? reads show channels like … output via content[:body]. relatel/switch#1258 makes it work with both formats, and it must ship before switch's scripts update librevox. A search of our repos found no other reads of parsed API output.

Needed by relatel/baritone's receptionist-prereqs branch (Controller#api, #get_variable). Both it and switch/receptionist pin this branch until it merges.

Tests

  • bundle exec rake test: 122 runs, including the new test_api_response_content_is_the_raw_body.

An api/response body is the command's output, not headers. Parsing it as
key-value lines mangled any output containing a colon: `global_getvar
hold_music` returning "local_stream://latin" came back as
{local_stream: "//latin", body: ""}. The content of an api/response is
now the raw body string. Events and command replies are parsed as before.
@henrikbjorn

Copy link
Copy Markdown
Member Author

Folded into #25, which collects these changes in one PR.

@henrikbjorn henrikbjorn closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant