cloudflare的worker中request参数里面包含有哪些信息

93 阅读6分钟

官方文档:Runtime APIs · Cloudflare Workers docs

里面包含很多运行时api,可以看看里面的参数都有啥,其实这个request的定义和web标准的request一致的:Request · Cloudflare Workers docs

我在本地测试得到的数据:

{
  method: 'GET',
  url: 'http://localhost:8787/',
  headers: Headers(16) {
    'accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
    'accept-encoding' => 'br, gzip',
    'accept-language' => 'zh-CN,zh;q=0.9,en;q=0.8',
    'cache-control' => 'max-age=0',
    'cf-connecting-ip' => '::1',
    'cookie' => 'Pycharm-f4332ef0=2f4ed5f5-3fdc-4e13-a458-30d766f272c0; _ga=GA1.1.330614322.1743398206; nf_lang=zh',
    'host' => 'localhost:8787',
    'sec-ch-ua' => '"Google Chrome";v="137", "Chromium";v="137", "Not/A)Brand";v="24"',
    'sec-ch-ua-mobile' => '?0',
    'sec-ch-ua-platform' => '"macOS"',
    'sec-fetch-dest' => 'document',
    'sec-fetch-mode' => 'navigate',
    'sec-fetch-site' => 'none',
    'sec-fetch-user' => '?1',
    'upgrade-insecure-requests' => '1',
    'user-agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36',
    [immutable]: true
  },
  redirect: 'manual',
  fetcher: Fetcher {},
  signal: AbortSignal { aborted: false, reason: undefined, onabort: null },
  cf: {
    clientTcpRtt: 186,
    requestHeaderNames: {},
    httpProtocol: 'HTTP/1.1',
    tlsCipher: 'AEAD-AES256-GCM-SHA384',
    continent: 'AS',
    asn: 17621,
    clientAcceptEncoding: 'gzip, deflate, br, zstd',
    verifiedBotCategory: '',
    country: 'CN',
    region: 'Shanghai',
    tlsClientCiphersSha1: 'JZtiTn8H/ntxORk+XXvU2EvNoz8=',
    tlsClientAuth: {
      certIssuerDNLegacy: '',
      certIssuerSKI: '',
      certSubjectDNRFC2253: '',
      certSubjectDNLegacy: '',
      certFingerprintSHA256: '',
      certNotBefore: '',
      certSKI: '',
      certSerial: '',
      certIssuerDN: '',
      certVerified: 'NONE',
      certNotAfter: '',
      certSubjectDN: '',
      certPresented: '0',
      certRevoked: '0',
      certIssuerSerial: '',
      certIssuerDNRFC2253: '',
      certFingerprintSHA1: ''
    },
    tlsClientRandom: 'PifbnzS1bUGeTkGfVPodpz6m9hmY25Zk4ppytrxRYxo=',
    tlsExportedAuthenticator: {
      clientFinished: 'ac4dd762388b278b5927cca9b7f169c78ce5c4664d7df28599935e7f2ee740a217412dab2e30faec0bb2e10455cdc5d7',
      clientHandshake: 'b792c6cd6d2661b7b15b2eae94d827093498a0870d33e4653b1494a53b52bbe76bcbc44a35c1f493d6ea8305c81b1d47',
      serverHandshake: '36ecd02f5384357bfa07465c99e94a4153f04cd7daa73118db49c4ef90bd5849d6d19806b196e1b707ce47853614e073',
      serverFinished: 'fb7f8bb1ddf3e5d15899e141e030416079b6f85969ee81f1290b7aa75669d9f3a68247ff189119e8795c30e742d5ef0b'
    },
    tlsClientHelloLength: '386',
    colo: 'SJC',
    timezone: 'Asia/Shanghai',
    longitude: '121.45810',
    latitude: '31.22220',
    edgeRequestKeepAliveStatus: 1,
    requestPriority: '',
    city: 'Shanghai',
    tlsVersion: 'TLSv1.3',
    regionCode: 'SH',
    asOrganization: 'China Unicom',
    tlsClientExtensionsSha1Le: '6e+q3vPm88rSgMTN/h7WTTxQ2wQ=',
    tlsClientExtensionsSha1: 'Y7DIC8A6G0/aXviZ8ie/xDbJb7g=',
    botManagement: {
      corporateProxy: false,
      verifiedBot: false,
      jsDetection: [Object],
      staticResource: false,
      detectionIds: {},
      score: 99
    }
  },
  integrity: '',
  keepalive: false,
  cache: undefined,
  body: null,
  bodyUsed: false
}
[wrangler:inf] GET / 200 OK (13ms)
fetch Request {
  method: 'GET',
  url: 'http://localhost:8787/.well-known/appspecific/com.chrome.devtools.json',
  headers: Headers(9) {
    'accept-encoding' => 'br, gzip',
    'accept-language' => 'zh-CN,zh;q=0.9,en;q=0.8',
    'cf-connecting-ip' => '::1',
    'cookie' => 'Pycharm-f4332ef0=2f4ed5f5-3fdc-4e13-a458-30d766f272c0; _ga=GA1.1.330614322.1743398206; nf_lang=zh',
    'host' => 'localhost:8787',
    'sec-fetch-dest' => 'empty',
    'sec-fetch-mode' => 'no-cors',
    'sec-fetch-site' => 'same-origin',
    'user-agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36',
    [immutable]: true
  },
  redirect: 'manual',
  fetcher: Fetcher {},
  signal: AbortSignal { aborted: false, reason: undefined, onabort: null },
  cf: {
    clientTcpRtt: 186,
    requestHeaderNames: {},
    httpProtocol: 'HTTP/1.1',
    tlsCipher: 'AEAD-AES256-GCM-SHA384',
    continent: 'AS',
    asn: 17621,
    clientAcceptEncoding: 'gzip, deflate, br, zstd',
    verifiedBotCategory: '',
    country: 'CN',
    region: 'Shanghai',
    tlsClientCiphersSha1: 'JZtiTn8H/ntxORk+XXvU2EvNoz8=',
    tlsClientAuth: {
      certIssuerDNLegacy: '',
      certIssuerSKI: '',
      certSubjectDNRFC2253: '',
      certSubjectDNLegacy: '',
      certFingerprintSHA256: '',
      certNotBefore: '',
      certSKI: '',
      certSerial: '',
      certIssuerDN: '',
      certVerified: 'NONE',
      certNotAfter: '',
      certSubjectDN: '',
      certPresented: '0',
      certRevoked: '0',
      certIssuerSerial: '',
      certIssuerDNRFC2253: '',
      certFingerprintSHA1: ''
    },
    tlsClientRandom: 'PifbnzS1bUGeTkGfVPodpz6m9hmY25Zk4ppytrxRYxo=',
    tlsExportedAuthenticator: {
      clientFinished: 'ac4dd762388b278b5927cca9b7f169c78ce5c4664d7df28599935e7f2ee740a217412dab2e30faec0bb2e10455cdc5d7',
      clientHandshake: 'b792c6cd6d2661b7b15b2eae94d827093498a0870d33e4653b1494a53b52bbe76bcbc44a35c1f493d6ea8305c81b1d47',
      serverHandshake: '36ecd02f5384357bfa07465c99e94a4153f04cd7daa73118db49c4ef90bd5849d6d19806b196e1b707ce47853614e073',
      serverFinished: 'fb7f8bb1ddf3e5d15899e141e030416079b6f85969ee81f1290b7aa75669d9f3a68247ff189119e8795c30e742d5ef0b'
    },
    tlsClientHelloLength: '386',
    colo: 'SJC',
    timezone: 'Asia/Shanghai',
    longitude: '121.45810',
    latitude: '31.22220',
    edgeRequestKeepAliveStatus: 1,
    requestPriority: '',
    city: 'Shanghai',
    tlsVersion: 'TLSv1.3',
    regionCode: 'SH',
    asOrganization: 'China Unicom',
    tlsClientExtensionsSha1Le: '6e+q3vPm88rSgMTN/h7WTTxQ2wQ=',
    tlsClientExtensionsSha1: 'Y7DIC8A6G0/aXviZ8ie/xDbJb7g=',
    botManagement: {
      corporateProxy: false,
      verifiedBot: false,
      jsDetection: [Object],
      staticResource: false,
      detectionIds: {},
      score: 99
    }
  },
  integrity: '',
  keepalive: false,
  cache: undefined,
  body: null,
  bodyUsed: false
}
[wrangler:inf] GET /.well-known/appspecific/com.chrome.devtools.json 200 OK (17ms)
fetch Request {
  method: 'GET',
  url: 'http://localhost:8787/favicon.ico',
  headers: Headers(14) {
    'accept' => 'image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8',
    'accept-encoding' => 'br, gzip',
    'accept-language' => 'zh-CN,zh;q=0.9,en;q=0.8',
    'cf-connecting-ip' => '::1',
    'cookie' => 'Pycharm-f4332ef0=2f4ed5f5-3fdc-4e13-a458-30d766f272c0; _ga=GA1.1.330614322.1743398206; nf_lang=zh',
    'host' => 'localhost:8787',
    'referer' => 'http://localhost:8787/',
    'sec-ch-ua' => '"Google Chrome";v="137", "Chromium";v="137", "Not/A)Brand";v="24"',
    'sec-ch-ua-mobile' => '?0',
    'sec-ch-ua-platform' => '"macOS"',
    'sec-fetch-dest' => 'image',
    'sec-fetch-mode' => 'no-cors',
    'sec-fetch-site' => 'same-origin',
    'user-agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36',
    [immutable]: true
  },
  redirect: 'manual',
  fetcher: Fetcher {},
  signal: AbortSignal { aborted: false, reason: undefined, onabort: null },
  cf: {
    clientTcpRtt: 186,
    requestHeaderNames: {},
    httpProtocol: 'HTTP/1.1',
    tlsCipher: 'AEAD-AES256-GCM-SHA384',
    continent: 'AS',
    asn: 17621,
    clientAcceptEncoding: 'gzip, deflate, br, zstd',
    verifiedBotCategory: '',
    country: 'CN',
    region: 'Shanghai',
    tlsClientCiphersSha1: 'JZtiTn8H/ntxORk+XXvU2EvNoz8=',
    tlsClientAuth: {
      certIssuerDNLegacy: '',
      certIssuerSKI: '',
      certSubjectDNRFC2253: '',
      certSubjectDNLegacy: '',
      certFingerprintSHA256: '',
      certNotBefore: '',
      certSKI: '',
      certSerial: '',
      certIssuerDN: '',
      certVerified: 'NONE',
      certNotAfter: '',
      certSubjectDN: '',
      certPresented: '0',
      certRevoked: '0',
      certIssuerSerial: '',
      certIssuerDNRFC2253: '',
      certFingerprintSHA1: ''
    },
    tlsClientRandom: 'PifbnzS1bUGeTkGfVPodpz6m9hmY25Zk4ppytrxRYxo=',
    tlsExportedAuthenticator: {
      clientFinished: 'ac4dd762388b278b5927cca9b7f169c78ce5c4664d7df28599935e7f2ee740a217412dab2e30faec0bb2e10455cdc5d7',
      clientHandshake: 'b792c6cd6d2661b7b15b2eae94d827093498a0870d33e4653b1494a53b52bbe76bcbc44a35c1f493d6ea8305c81b1d47',
      serverHandshake: '36ecd02f5384357bfa07465c99e94a4153f04cd7daa73118db49c4ef90bd5849d6d19806b196e1b707ce47853614e073',
      serverFinished: 'fb7f8bb1ddf3e5d15899e141e030416079b6f85969ee81f1290b7aa75669d9f3a68247ff189119e8795c30e742d5ef0b'
    },
    tlsClientHelloLength: '386',
    colo: 'SJC',
    timezone: 'Asia/Shanghai',
    longitude: '121.45810',
    latitude: '31.22220',
    edgeRequestKeepAliveStatus: 1,
    requestPriority: '',
    city: 'Shanghai',
    tlsVersion: 'TLSv1.3',
    regionCode: 'SH',
    asOrganization: 'China Unicom',
    tlsClientExtensionsSha1Le: '6e+q3vPm88rSgMTN/h7WTTxQ2wQ=',
    tlsClientExtensionsSha1: 'Y7DIC8A6G0/aXviZ8ie/xDbJb7g=',
    botManagement: {
      corporateProxy: false,
      verifiedBot: false,
      jsDetection: [Object],
      staticResource: false,
      detectionIds: {},
      score: 99
    }
  },
  integrity: '',
  keepalive: false,
  cache: undefined,
  body: null,
  bodyUsed: false
}