@@ -51,6 +51,7 @@ import {
5151 CACHE_ONE_YEAR ,
5252 HTML_CONTENT_TYPE_HEADER ,
5353 NEXT_CACHE_TAGS_HEADER ,
54+ NEXT_RESUME_HEADER ,
5455} from '../../lib/constants'
5556import type { CacheControl } from '../../server/lib/cache-control'
5657import { ENCODED_TAGS } from '../../server/stream-utils/encoded-tags'
@@ -121,6 +122,10 @@ export async function handler(
121122 if ( routeModule . isDev ) {
122123 addRequestMeta ( req , 'devRequestTimingInternalsEnd' , process . hrtime . bigint ( ) )
123124 }
125+ const isMinimalMode = Boolean (
126+ process . env . MINIMAL_MODE || getRequestMeta ( req , 'minimalMode' )
127+ )
128+
124129 let srcPage = 'VAR_DEFINITION_PAGE'
125130
126131 // turbopack doesn't normalize `/index` in the page name
@@ -135,10 +140,6 @@ export async function handler(
135140 const multiZoneDraftMode = process . env
136141 . __NEXT_MULTI_ZONE_DRAFT_MODE as any as boolean
137142
138- const isMinimalMode = Boolean (
139- process . env . MINIMAL_MODE || getRequestMeta ( req , 'minimalMode' )
140- )
141-
142143 const prepareResult = await routeModule . prepare ( req , res , {
143144 srcPage,
144145 multiZoneDraftMode,
@@ -219,6 +220,25 @@ export async function handler(
219220 nextConfig . experimental . ppr
220221 )
221222
223+ if (
224+ ! getRequestMeta ( req , 'postponed' ) &&
225+ couldSupportPPR &&
226+ req . headers [ NEXT_RESUME_HEADER ] === '1' &&
227+ req . method === 'POST'
228+ ) {
229+ // Decode the postponed state from the request body, it will come as
230+ // an array of buffers, so collect them and then concat them to form
231+ // the string.
232+
233+ const body : Array < Buffer > = [ ]
234+ for await ( const chunk of req ) {
235+ body . push ( chunk )
236+ }
237+ const postponed = Buffer . concat ( body ) . toString ( 'utf8' )
238+
239+ addRequestMeta ( req , 'postponed' , postponed )
240+ }
241+
222242 // When enabled, this will allow the use of the `?__nextppronly` query to
223243 // enable debugging of the static shell.
224244 const hasDebugStaticShellQuery =
0 commit comments