Skip to content

Commit

Permalink
fix: use normalized headers
Browse files Browse the repository at this point in the history
This ensures support for HTTP/2
thank you @KABBOUCHI !
  • Loading branch information
eidellev committed Mar 7, 2023
1 parent e56c464 commit b7c53d9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion providers/InertiaProvider/InertiaProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export default class InertiaProvider {
Response.macro(
'redirect',
function (path?: string, forwardQueryString: boolean = false, statusCode = 302): RedirectContract | void {
const isInertia = this.request.rawHeaders.includes(HEADERS.INERTIA_HEADER);
const isInertia = this.request.headers[HEADERS.INERTIA_HEADER];
const method = this.request.method;
let finalStatusCode = statusCode;

Expand Down
12 changes: 6 additions & 6 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export enum HEADERS {
INERTIA_HEADER = 'X-Inertia',
INERTIA_PARTIAL_DATA = 'X-Inertia-Partial-Data',
INERTIA_PARTIAL_DATA_COMPONENT = 'X-Inertia-Partial-Component',
INERTIA_VERSION = 'X-Inertia-Version',
INERTIA_LOCATION = 'X-Inertia-Location',
VARY = 'Vary',
INERTIA_HEADER = 'x-inertia',
INERTIA_PARTIAL_DATA = 'x-inertia-partial-data',
INERTIA_PARTIAL_DATA_COMPONENT = 'x-inertia-partial-component',
INERTIA_VERSION = 'x-inertia-version',
INERTIA_LOCATION = 'x-inertia-location',
VARY = 'vary',
}
1 change: 1 addition & 0 deletions test/validation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ test.group('Validation negotiator', (group) => {
});
}
});

test('Should use vanilla validator for HTML requests', async (assert) => {
const app = await setup();
const ctx = app.container.use('Adonis/Core/HttpContext').create('/', {});
Expand Down

0 comments on commit b7c53d9

Please sign in to comment.