Download next.js/packages/next/src/server/lib/streaming-metadata.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 855 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/server/lib/streaming-metadata.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/next.js/packages/next/src/server/lib/streaming-metadata.ts
-
curl -L -o streaming-metadata.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/next.js/packages/next/src/server/lib/streaming-metadata.ts
855 Bytes
| import { | |
| getBotType, | |
| HTML_LIMITED_BOT_UA_RE_STRING, | |
| } from '../../shared/lib/router/utils/is-bot' | |
| import type { BaseNextRequest } from '../base-http' | |
| export function shouldServeStreamingMetadata( | |
| userAgent: string, | |
| htmlLimitedBots: string | undefined | |
| ): boolean { | |
| const blockingMetadataUARegex = new RegExp( | |
| htmlLimitedBots || HTML_LIMITED_BOT_UA_RE_STRING, | |
| 'i' | |
| ) | |
| // Only block metadata for HTML-limited bots | |
| if (userAgent && blockingMetadataUARegex.test(userAgent)) { | |
| return false | |
| } | |
| return true | |
| } | |
| // When the request UA is a html-limited bot, we should do a dynamic render. | |
| // In this case, postpone state is not sent. | |
| export function isHtmlBotRequest(req: { | |
| headers: BaseNextRequest['headers'] | |
| }): boolean { | |
| const ua = req.headers['user-agent'] || '' | |
| const botType = getBotType(ua) | |
| return botType === 'html' | |
| } | |