Skip to content

Commit

Permalink
Use x-ndjson
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismccord committed Feb 17, 2023
1 parent 36b2c16 commit bd3ce36
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion assets/js/phoenix/longpoll.js
Expand Up @@ -123,7 +123,7 @@ export default class LongPoll {

batchSend(messages){
this.awaitingBatchAck = true
this.ajax("POST", "application/ndjson", messages.join("\n"), () => this.onerror("timeout"), resp => {
this.ajax("POST", "application/x-ndjson", messages.join("\n"), () => this.onerror("timeout"), resp => {
this.awaitingBatchAck = false
if(!resp || resp.status !== 200){
this.onerror(resp && resp.status)
Expand Down
2 changes: 1 addition & 1 deletion lib/phoenix/transports/long_poll.ex
Expand Up @@ -75,7 +75,7 @@ defmodule Phoenix.Transports.LongPoll do
# we need to match on both v1 and v2 protocol, as well as wrap for backwards compat
batch =
case get_req_header(conn, "content-type") do
["application/ndjson"] -> String.split(body, ["\n", "\r\n"])
["application/x-ndjson"] -> String.split(body, ["\n", "\r\n"])
_ -> [body]
end

Expand Down
2 changes: 1 addition & 1 deletion test/phoenix/integration/long_poll_channels_test.exs
Expand Up @@ -161,7 +161,7 @@ defmodule Phoenix.Integration.LongPollChannelsTest do
{serializer, json} = serializer(vsn, json)
headers =
if is_list(json) do
Map.merge(%{"content-type" => "application/ndjson"}, headers)
Map.merge(%{"content-type" => "application/x-ndjson"}, headers)
else
Map.merge(%{"content-type" => "application/json"}, headers)
end
Expand Down

0 comments on commit bd3ce36

Please sign in to comment.