diff --git a/src/core/drive/form_submission.ts b/src/core/drive/form_submission.ts index 460c9ba0e..3c89a2a05 100644 --- a/src/core/drive/form_submission.ts +++ b/src/core/drive/form_submission.ts @@ -2,7 +2,6 @@ import { FetchRequest, FetchMethod, fetchMethodFromString, FetchRequestHeaders } import { FetchResponse } from "../../http/fetch_response" import { expandURL } from "../url" import { dispatch } from "../../util" -import { StreamMessage } from "../streams/stream_message" export interface FormSubmissionDelegate { formSubmissionStarted(formSubmission: FormSubmission): void @@ -153,7 +152,6 @@ export class FormSubmission { if (token) { headers["X-CSRF-Token"] = token } - headers["Accept"] = [StreamMessage.contentType, headers["Accept"]].join(", ") } } diff --git a/src/http/fetch_request.ts b/src/http/fetch_request.ts index b10f5c843..3e614fab3 100644 --- a/src/http/fetch_request.ts +++ b/src/http/fetch_request.ts @@ -1,6 +1,7 @@ import { FetchResponse } from "./fetch_response" import { FrameElement } from "../elements/frame_element" import { dispatch } from "../util" +import { StreamMessage } from "../core/streams/stream_message" export interface FetchRequestDelegate { referrer?: URL @@ -137,7 +138,7 @@ export class FetchRequest { get defaultHeaders() { return { - Accept: "text/html, application/xhtml+xml", + Accept: [StreamMessage.contentType, "text/html", "application/xhtml+xml"].join(", "), } } diff --git a/src/tests/functional/form_submission_tests.ts b/src/tests/functional/form_submission_tests.ts index e407d9055..50f02c39b 100644 --- a/src/tests/functional/form_submission_tests.ts +++ b/src/tests/functional/form_submission_tests.ts @@ -157,7 +157,7 @@ export class FormSubmissionTests extends TurboDriveTestCase { const { fetchOptions } = await this.nextEventNamed("turbo:before-fetch-request") - this.assert.notOk(fetchOptions.headers["Accept"].includes("text/vnd.turbo-stream.html")) + this.assert.ok(fetchOptions.headers["Accept"].includes("text/vnd.turbo-stream.html")) await this.nextEventNamed("turbo:before-fetch-response") @@ -486,7 +486,7 @@ export class FormSubmissionTests extends TurboDriveTestCase { const { fetchOptions } = await this.nextEventNamed("turbo:before-fetch-request") - this.assert.notOk(fetchOptions.headers["Accept"].includes("text/vnd.turbo-stream.html")) + this.assert.ok(fetchOptions.headers["Accept"].includes("text/vnd.turbo-stream.html")) this.assert.equal("frame", fetchOptions.headers["Turbo-Frame"]) await this.nextEventNamed("turbo:before-fetch-response")