mirror of
https://github.com/withastro/astro.git
synced 2025-01-27 22:19:04 -05:00
fix: don't set statusMessage in HTTP/2 (#12147)
This commit is contained in:
parent
46cbf10c4b
commit
9db755ab7c
3 changed files with 17 additions and 2 deletions
7
.changeset/strong-pugs-stare.md
Normal file
7
.changeset/strong-pugs-stare.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Skips setting statusMessage header for HTTP/2 response
|
||||||
|
|
||||||
|
HTTP/2 doesn't support status message, so setting this was logging a warning.
|
|
@ -6,6 +6,7 @@ import { createOutgoingHttpHeaders } from './createOutgoingHttpHeaders.js';
|
||||||
import { App } from './index.js';
|
import { App } from './index.js';
|
||||||
import type { RenderOptions } from './index.js';
|
import type { RenderOptions } from './index.js';
|
||||||
import type { SSRManifest, SerializedSSRManifest } from './types.js';
|
import type { SSRManifest, SerializedSSRManifest } from './types.js';
|
||||||
|
import { Http2ServerResponse } from 'node:http2';
|
||||||
|
|
||||||
export { apply as applyPolyfills } from '../polyfill.js';
|
export { apply as applyPolyfills } from '../polyfill.js';
|
||||||
|
|
||||||
|
@ -108,7 +109,10 @@ export class NodeApp extends App {
|
||||||
*/
|
*/
|
||||||
static async writeResponse(source: Response, destination: ServerResponse) {
|
static async writeResponse(source: Response, destination: ServerResponse) {
|
||||||
const { status, headers, body, statusText } = source;
|
const { status, headers, body, statusText } = source;
|
||||||
destination.statusMessage = statusText;
|
// HTTP/2 doesn't support statusMessage
|
||||||
|
if (!(destination instanceof Http2ServerResponse)) {
|
||||||
|
destination.statusMessage = statusText;
|
||||||
|
}
|
||||||
destination.writeHead(status, createOutgoingHttpHeaders(headers));
|
destination.writeHead(status, createOutgoingHttpHeaders(headers));
|
||||||
if (!body) return destination.end();
|
if (!body) return destination.end();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import type http from 'node:http';
|
import type http from 'node:http';
|
||||||
|
import { Http2ServerResponse } from 'node:http2';
|
||||||
import type { ErrorWithMetadata } from '../core/errors/index.js';
|
import type { ErrorWithMetadata } from '../core/errors/index.js';
|
||||||
import type { ModuleLoader } from '../core/module-loader/index.js';
|
import type { ModuleLoader } from '../core/module-loader/index.js';
|
||||||
|
|
||||||
|
@ -67,7 +68,10 @@ export async function writeWebResponse(res: http.ServerResponse, webResponse: Re
|
||||||
if (headers.has('set-cookie')) {
|
if (headers.has('set-cookie')) {
|
||||||
_headers['set-cookie'] = headers.getSetCookie();
|
_headers['set-cookie'] = headers.getSetCookie();
|
||||||
}
|
}
|
||||||
res.statusMessage = statusText;
|
// HTTP/2 doesn't support statusMessage
|
||||||
|
if(!(res instanceof Http2ServerResponse)) {
|
||||||
|
res.statusMessage = statusText;
|
||||||
|
}
|
||||||
res.writeHead(status, _headers);
|
res.writeHead(status, _headers);
|
||||||
if (body) {
|
if (body) {
|
||||||
if (Symbol.for('astro.responseBody') in webResponse) {
|
if (Symbol.for('astro.responseBody') in webResponse) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue