请求

req 对象表示 HTTP 请求,并具有请求查询字符串、参数、正文、HTTP 标头等的属性。在本文档中,按照惯例,该对象始终称为 req(HTTP 响应为 res),但其实际名称由您正在使用的回调函数的参数确定。

例如:

app.get('/user/:id', function (req, res) {
  res.send('user ' + req.params.id)
})

但你也可以拥有:

app.get('/user/:id', function (request, response) {
  response.send('user ' + request.params.id)
})

req对象是Node自带请求对象的增强版,支持所有内置字段和方法

req.app

此属性包含对使用中间件的 Express 应用程序实例的引用。

3syuHkPqQ0PAq2NAmBG7FWYcdokZbmHCrzgWNiT97vK9DxQEneIgG/9NlHWFWUevVE3YwGa0WDaqIFNjmpxQNzj4Hu/Jt64DG13w7XpnhfZnY/32LO5ynexIPs7r92nuYQz/P9karilPtr9UwFkFugNmz82cQl5vnBnKNel0bJ8318hj1JI7Mkaf9HO5Vg9gGtkjAvmB+YiKRTea/cCJJOMF+kKdW99cosbIIFmBscDIBVaM9YiYm0qw4W40fmEICeDhjd45LefkFx3hu67miA==

4h5+3DAGYIrQZh8xCRRFCA==

// index.js
app.get('/viewdirectory', require('./mymiddleware.js'))
// mymiddleware.js
module.exports = function (req, res) {
  res.send('The views directory is ' + req.app.get('views'))
}

req.baseUrl

cfd8cQgxsU8o4ceNazft/IJauo4W6scyJ7qlzMyrX1+p+4XgoocYrdX5rNnjgy/m

951AiV64YvuExLHp5iLgUrnR8qC8/YAhjPKzZctY0Onfag/1SoR0HhLmGgnh5BcH6inqVhtHZp7E+EUNR7qOmhDKv4F1bApyTqrjQqrfv2zkHPuYdPDOvXyXN2BYMSuwfAA+CjDqdI/SRK+b3i3A0QJfodINhl3Tmynfoqgi5Ao5+j0l1gJBnLbaQSitc60CfI+qvgGpnTY0mMYby9hfpYKs28zn7KRw4jAlK7xcTOnUpjGXNfpGJ4uG5QF5eRDnWjSk0qSZzNrByhDjgBtesA==

4h5+3DAGYIrQZh8xCRRFCA==

var greet = express.Router()

greet.get('/jp', function (req, res) {
  console.log(req.baseUrl) // /greet
  res.send('Konichiwa!')
})

app.use('/greet', greet) // load the router on '/greet'

VLdPLSOOgpp1qoYzlyYej0MAKrbX7NrVi22TVX9MjixBJYI3O6rX8OLU8bBTmMGFpSKwHcy9DmFAeWsR6u63RMbw8QnRD0ahR/hBWRmeXn1323YdyfFWC533mB2tS1l+KZrojaX9UgGcy1clzy0LdXvV4Z+DNEmRR5Z+c5q8jVRGDEp29ljbasSMq4o33ia/xpBgXV7H6RNet7JPr0fFc4psr3tEzodWZHmysTPq/NiQCF5egBWsCeVt7dAhwcfm7n5WngHIsXNdTsWigjc05nx+fdHfPIpo9ulrwnQyi1U=

app.use(['/gre+t', '/hel{2}o'], greet) // load the router on '/gre+t' and '/hel{2}o'

FfksolmwZUJcFF/nDyasUJfCdM8V2Rx4o3vC23dG6YHIAQs2WNwniTxbb/iJgSBqJV0nLxCGPYGXtAA7VdnFsjVQf+/nVFYbWtYPalFDKTdbobS6ZD+OBOePwyDjnAcrs0ZU5CM2ffnVcV20T/v8ETIJkwzxmLTW907JuSpCHPKh/daccE6RwBQ4aFoF717VA9DNpJeEgO+kOmj3nfdplUQ7EuhwaqcMT6/kA6Fyj2+RRjsBXbUf/TvhvdyD4hJ/

req.body

1xB5Urn1GGxKKEutp3/rpnKA4JwOniSC2DOn1uDlm2VueH6q/lcsROgPnW/BOpg4iIztRzmT/JaeS1l5hKgd9NYMev0usvx1gbUjATzmLZdNlTDJdQ9wCjVjxuL0wT0xFvTk/IXRRrg2la/3D14VtQ01QumfTUH9jBb4CTQHm4gEo7movnydG3U8KHf8zCvylrAmw+45i6XByL4MN19JI0ZchyFe8u0941YL3PqkJvLzKDKPDzddB769PVE4xrX4zn8+MayqpJlZDjJ6VeJjz1OZahm8TnwqEmaK+XSrphzGoZbGhjpY4GDXpqKrXrMFB72ReMUaP1Ef7MMWgucbgpJbTwKFFp5O3a8Poha3M+2i67s3nm12emlhsaLljAfnYwLafjw80vsPSAcEaa4iuPZw+3BAbvFOSoDGsU+rspM=

CEE+c2tOj7HBPk4SmWZa4yEZk26sNOh+QPjevfvManqg11YJhQgFfrfcSEeoAq/4xN2v9bCrqAm4xYR4eEbb8zCZ/zUrLz15LqdQZs/NlEpVDLwvc/eBGOmpy7OyElKcVnqaEsfl3Ar8oc09MmacGjvkKUxMBFgvmZ2wj6uwgEaExCl+mBeYnN03BM5Vy516+uXzpV32hl4H1NJt2RMbkdwIRoDdO+MBabv/oQsBRUI9PKaqmxPpN2K3el6VV0z/iwl0u+ilX+9olSelFyxgPOSOVSX5dTbpdG5BnCJJZOuOXHigEq3kAcX9tP1hAcewzunLPurCLuza3o1J29US7/+U/PoIGqUhTAv2Xnp2U4p3IC+SkVWwJ1nEO50J3EYexiyVtJcDFSNc8Hoid+mH7cOmiJc74456k3SsW6B2V04SdVkuhhkVjMAdEdw45xLPZP6Kg1uvwBbncIB0vmzuqpFlo6TUQIhTrFtr72ugs6d6SdZpy8gruGn4OH+7gusjziq87Jab2V4Jy79N4YFB/A==

laCjC9T/Bas0TOIMbqegKBQSO8Fz+6DIf1Qb9JXHi6aj2NoTDu1vJYV/hF+wv03diDtsMXfd7A+eAFr3g6UbWeVSdjf2OrFG7v4RAIisr2uqyI8lyW2Fydxw16NuvOsx

var express = require('express')

var app = express()

app.use(express.json()) // for parsing application/json
app.use(express.urlencoded({ extended: true })) // for parsing application/x-www-form-urlencoded

app.post('/profile', function (req, res, next) {
  console.log(req.body)
  res.json(req.body)
})

req.cookies

BpDIkXRUnkPiBz8iBceshHRho+n2gRQ/Ye0EOGheBhDUobeNi1kK4uP4CBLDHFAkUXNBvfKktLS9DV+CYNGZbJnI8zl7E8t0uauViSrVpaj/a+bCHkTwByl+/i9MernD50PorQDpo6lai5cGnwJwnPXtf5Uv5SYRH4fMH/BRY5CxN85jldnxWcXNW6mQZMJDE8diVbKu+Oq2xFZ/zVjx5T9ZqawbkkxREaG+hEUYaVK/6eXvYJnkn/i1fgjwb7Qn8viXsHWCdTm6r5ZPLQcuww==

// Cookie: name=tj
console.dir(req.cookies.name)
// => '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Gmj61g=

req.originalUrl

AJ4l3JnmCeQG6JfsCGyN5vTMjDgTRNTmBKWXJJ9S0nbFy80hGPuBQjWh5uSXRq6pwwrdL7vkEbOsEi3N0pqCmi4NKkg6pXKzMJua84b6DxrjybpkR9WtMAJstX3TPs8iGQdRbyvyx/GNMSzcJJcTmc+Pfmarcbu0oeOmcgCSoDA7uPRcDbgb8QBxHfOIfkn4

fFkdqu8VIxruWJnorY6Y2MpQKhutBNfdvbij17zBJOzFEPj4UBnRHNgo0wlFATjRTm0AVWuCZKrUr/7RuInHoJfTNxk4N3cCq+qMqMdTkANzhyYMx5r0SCdVQ7uLkFehUz0EIzWYzAvrb5oE8WeeWEo/sTXT+XEjkkkaKzQfAUi3lwgmAgK6/P0MnYybqCiX86zeFr/d+jIVXMczJtz3IIHEefuGzYhpehMkrvbdIipQ/He0Xwh+2xvlAFpiqtgDoiuLFUGDk65blrbjoXbfZa++iB/vPRJMwN21E1LpQ4ZxVaKdRSzJq4KLtjWV3hqMHeGI3IlKjwA5uwNdi9f3sgj7oRXNUznxuEP0CS/whySWYcWyklvJUUkAU9mvjlmToTOpNb5K1z2pwS68wAmLew==

// GET /search?q=something
console.dir(req.originalUrl)
// => '/search?q=something'

GaTx6MjTW3HWnP1vId+6LvraqTGygafnAu0824A7lDrGfiG48+pQyZAuAyzbWXmA4IoHzjBDeKNP7QsgQnXh04c0wNQuEi8H4OJOkxW4JuQiQtczL5ehJdo2A4d/zfwbM1FK0RziMKZuIU+7i25wAagQIRMpQsbNLR7GkPN7fiHxgPHu0gYUnQfPLESzEhsridAwUHiHCX6IDdKrol3aWSEOWL4OGiV+UgYnHKKILuk=

app.use('/admin', function (req, res, next) { // GET 'http://www.example.com/admin/new?sort=desc'
  console.dir(req.originalUrl) // '/admin/new?sort=desc'
  console.dir(req.baseUrl) // '/admin'
  console.dir(req.path) // '/new'
  next()
})

req.params

pQtsVgzX4Wlriy0tAl8Ok4Frr1e0yx+hypsnJVEw9/ykruWJ2zNn3rqNFtOVGpAUQo0qXXI85Z5VsChL7oi0oPgiNSTaqGJQLucN02esUFhmVHfZ2pHDXOd7XJJBLwEz/SieT/TPb4zwr5U2AK+VSjB0ogaRS3HKX7JFfVDZH82PSCtt7ga72UxZ12dlzwoZD8PnHaa/puK0njSg4q5CFkhxynTAVTDGp3sG7NRgV5GJJjcT+LyFEy0T/WrQVYxIwPA57ClJW9TCy1MElmzHbVmGgitJIaWGRUIQ3HvmlZdblXe+h13OXliVQndpa8rp6QkvRGECKKmqmeBSEqqgKpyIq5l3Oj4mVrzIZkwuXSU8/08v/hv0FIAkZxqPMdn4

// GET /user/tj
console.dir(req.params.name)
// => 'tj'

Vn8I062MpExQ/xlNBkGhab5EuGs73FrYRKtehOTPohczjwrlANhVju0Vwrw7iYLrJQ3xeQKzbPazWJcSSzcj1D1l9DZhYWOwinPEo/puG6hLpcXQrDOB9fopEycFMm1iGYkhKoD6bP7Uhtkys58kKPy8iACNh/NBDxuiileopEl/1DlKo80oxfasOQ9Vf2P1mScivfo+2u8IfaEI3NZXwqLZSwGR/cDluJkmlpkiKne4i4D90zSx3hdTwLQxMNWYsQzxyp59dO3LvlvC+G5a/TBJO+jjTAuFq6ITV8MEBKnN1oTNQ2eL5IsmG26D7k+PurgIJa1GNRHXyXCyImEJiAKqrWuhG7ge9htLjHvyT0M=

// GET /file/javascripts/jquery.js
console.dir(req.params[0])
// => 'javascripts/jquery.js'

CMyfzLNJZrUlcHFBSDtMgvdDZ+LbcgwrzzrJUFLQqNdQbH7uW/uiV8yrExDDPxEd7Xv7+QeEsg8cwVvm8+teApB1mRGJ2av87d92sdZu2gaFin7jnHdOuME4vDERTCoDClBIxWcC7UQjvfzIKn3WPhw1V9bCFX+m4M86FKI5HTSPcTbFO+1VeB7sh5ZW/MEpA8M3HHRJ9anHGFPwNvC8RQFubDR2yVdhL1OOS0F6DukScOCs/qlyGTvHFTpNbbxYGkyqgXxH+Ai9Q8Qe96UOuHbyt2j3i296WgMVjv7OOuCypojM4T5uJxeRxXi/QD3+SVftjQ1316fFB9iuAq2eHA==

W42mVb62rBYz2pXLvBLmgolMfSy62fgF/jCuKucfFJFB2NbZlzlQ/9yF5tL4bkpoKR6SsxtNZhUCEMh0EWLJZCQ04652g0p4H1tFKO/GNlk1cWehSWRbZJu32yjRkA3LJ79PS7qXpR4B7ZyWvnUsuA==

NTW5j9kMzXlX+G60B/WceJZwyxoFMz+s4NZIYtQAnKHnkPXaI1DuB6TPYUMkNfjQjS7MZ/jT9ObzOmIMogzCO4wBVn8fkOSVX9c6yVCERahN4ZKudMSTZuDpMiPZqd1Hgy3+XT7qSRqmLWOedSSXRQ==

req.path

bRq87VxNG5+St2HKHlPFH9h+N+DyHjEVp9mvojSA7ND/uA0CkdlRFsSwhllGNxBS

// example.com/users?sort=desc
console.dir(req.path)
// => '/users'

ZzqpOuGbKO0HrOpGhboBcIul/CPtMbK7KUFvInFVC5Mq+DwBrtxTe+zxpNdZJLLA1GxBcENqS105dxNa/Ca/nKismhfN9xIZUzSi2h3lt1v/jivMhDCN2f7JxZghUp0/FoSiSXAHvTzArhl14eL5yvvFepfM75mZsI+BabAD+kXFklmwk4M11RnJKysAuHuH2LE1utTqcSK2XjLGml5kGOtWy+B6ezkl11eLGPKojC8=

req.protocol

H17HOl8dOVoFCEg8EpQU0aOVn1uqnQDQ9Y4vbn2xG3Z3sxvrVQWJpSGjcpRJ26gMb5IMPckg7pCiCjfOLPXVnT9uYh6abWV/n8NWgii9DBPfm5vftz0o0knHqjbgEYku

rgWSxfOgo+p8e8ez2ciW6tyMVGtEK2YnkKwDCdITMsa01G+rgEgctIDJBurIm1X1xwQhcf+AzJOGYcb/C2jyZWI3H25Bcn+9Huul9aCQesUruZ9ILPF0t/sawstpWE9r/R5kjDJkmg1xsDnljX8D/Lbm4gYR7+Emv/ZgFlnmj9OkqyK0ODkJcaoLo+ZVzCqCfCHZmPR6LjEdA3jI8oHk+mzKatBv0UoR8CfLD4FcvkEGZxmZx4Ze0PPzD7kBDm8jeeLEIk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vIgnUP+r+J3AVoBFu1p2P0zHoz9hjNDOMulIP4IEkHQdRqV8/XB61YO1wURlxSrN8gTCeg40QqkB/hPa7IssVVwAWijRUAkCT0fNW9jEKVqR/HUN3t75dCbSZPu+6cnFvosaR1McebmsgGQTBsm7M907DMkvrviF4cM/mhvF8XY8cziStxEG2BmsseYfCySckKG3BFiwwnOqmFK0juQSXDL3ZhDDdAOmMDjcwGheIU5QzwhOffRjfU/kq3DAbOHDKdKMoIkDfo1yuaYHUWOdIkFeYbHW70/ObTv/Jg0J1192FR1G+KrtcYmFvznMDdD6aNsHFZ5bC4lnD8sYqRmtBPpt++I0a96ATdGxlfFvc881u9Q0t4kdPUFu/TZ6LF74n1Hj3xiswyEPPENyIj3uE5X/z1XCxC8yuFtm8Jk4orW6RVKcF2B+Ll2uxFKG+vvHj8XvoBQdWvzYYGN8ku/s0iQjHRSPuAGMI+CdFVdvJHcu8M9aO0fOcjwJC41RUiHzuGRPpTOqqGvyEYQz5+9PcosGl8fVXO8Qr5ojXCrFAhc4TXJ63v8K90EnMsw=

var qs = require('qs')
app.setting('query parser', function (str) {
  return qs.parse(str, { /* custom options */ })
})

xuu7IDQrdDS8aOZtgxsAzWqDTnx++hYqoGwfezEItOwk3nj110bJ1pqNRyTmvnOlZWvF4vOE1ogcWRx/eH2epz+xfxRYYEQG9jSjnoQRnfsHz4pSanU4iDXVua5nnij3Yg4j+C+YpQLW2W/HbvEJzQG2aivupmBpQoKWm2hxdPY=

req.res

B0Y2h48Xu5+yWZnT7DQ5LLzc2pXKuCmv2T5Kv13FizEoJ93/wHt1tt6WB/buPp7/R2Y0PxvvqoAWOuGQRfppzll0oKrvgrH5jidY7AY0MYF6Zgi9p0TNmDIGkPf2LlMJ/Q88QdLdND6IaYrn9BF0JsyxYjWOLqSIjjkJ2sT6bY0=

req.route

8VID1cYaBXYrXVuxGTMkPmoWGt5ZgRT7rXU82ymzvd2OKI4lOCxzhk0JeW3yBdfUeFXaGJ0+pB6f86lqCTbAQg==

app.get('/user/:id?', function userIdHandler (req, res) {
  console.log(req.route)
  res.send('GET')
})

sGkJOgUtyHH5mL1h1gYSHFihwmChP5UzYqkXXnrGS2xyvpnWlQQyBxVy8YTAYWXs

{ path: '/user/:id?',
  stack:
   [ { handle: [Function: userIdHandler],
       name: 'userIdHandler',
       params: undefined,
       path: undefined,
       keys: [],
       regexp: /^\/?$/i,
       method: 'get' } ],
  methods: { get: true } }

req.secure

aCqAQ+Fqd7hkNpeEerrHjQP11PNfoJKwD9OeWgeU/Uifz82dVoRXnL4H9Pf7tLj831TvopjU7jfdYAVT7Wb3eNZmjoOYVrQRayKHSDMgnX4=

console.dir(req.protocol === 'https')
// => true

req.signedCookies

BpDIkXRUnkPiBz8iBceshHRho+n2gRQ/Ye0EOGheBhDUobeNi1kK4uP4CBLDHFAkUXNBvfKktLS9DV+CYNGZbJnI8zl7E8t0uauViSrVpahwlwk1c8vlqYRU5fxHG4cHr82oVJo6oC4+la1XdDtkHX2IC2Z2+kUtLIQHP2y9gb03l13veHMSDKGKjVS8ERs9QM9HWoB0/XhVg8twppHQQ+7W/TkBm+zE7VEjo+QFerMUeCE+iE6gfE5rqHEXAyuISy3Y81yZhW72AgLi40Zd2Kem4BKlUe0ELrIGfu5X/RXnWr00o+WtPWRn2yA87c5vF2lgzeCYIYJFwDPAlYI16MiKLE8B+9YQpzh5ZHOzrbBen5jwsy1GT0oZ8QFaUXLwBZOYU6dDmkGKrfL4RsUB2XWP4FpzNUY7TSWqKxq8xPbkOH1uKrCoCpKphIsP3xt6LzvgdNLJliNHoFv2kPHzwPg9+HGztNfer8hTQMQx9hgEgi14MZlJJymgGItCmT5RW60JfdR9iiToci8PB2MzEsjvhfgL57DjuAuhwOi3Q0rTdpPkoj32+QR2yrScSnItSHfeD4OYW+zCuiLn3MXzLw0ZUMHm1VjyE9+ru9V/R9i7tRa/Kb371vxhp3baCOf+

o7bKJJuxIKU76Am5eiTNMOJiFGJXD3+f6VhTXWBjrDyxkHvc9LkmvjCBih9Tt6y74YNnMk+467cS5UHjBhF0lJV+uKSAs/y16uZDUwD5390=

// Cookie: user=tobi.CP7AWaXDfAKIRfH49dQzKJx7sKzzSoPq7/AcBBRVwlI3
console.dir(req.signedCookies.user)
// => 'tobi'

vLQ6D36bWQ06eLzFTMHAxKaZxH3b9Qa+BBdXc9GjSgEZN70crj60HbX4lL6sgLOHEtNuSjBJIUH6gj2zGZS/xl8f7irZC8Tf++DMvQcdmIbvYCD2ShPXIarxvGNhThiyOHZmw7zLIH2eP54AOlF8LoLjZyvIhhoYiMp/yTilKQ4=

req.stale

ffqa3DwI54yWedHbNB3K2OL9MBLv5sISdnJ9j5DPfl6NU3NLmqUp+XMA0wEoNvH+83k+uQtbsHqZTSXcN6Mkcx225ovr3Jq63taz2ObHpq9IjeR4jtOU8DDeI9fFyAZS5Qmq0svAaRzb6dt8xyVAUD3Sq09t9sT0HgJGjnb6IJsvOzArVRhjIFDUnCELT50YfmuC2i6xD1JQlS2e5pJC9w==

console.dir(req.stale)
// => true

req.subdomains

9u7uXf9bP09ZavqsmtsJ5OGPVg/ayanJ0ummkQTgtJP2u4q5/jfaC+PtR4drLeLI

// Host: "tobi.ferrets.example.com"
console.dir(req.subdomains)
// => ['ferrets', 'tobi']

JrmE6zcd4AdTuouISKWc4q4stkl+O17VtcwpAMrlk3LiYeETmGJGHXejhxpuKWHlbYyJt+kSHXttJb4qet2etxYAMFzvcgpV9k2lgESeTdEkB8PHW8pnokY9bQtkiZZjg7N2zNp3CfN+3xIQo0HPPA1u1Nf+csI9fri5E5jPX8E+q/3xxAjDGHO4SC6P4D5dwx72xdtrUZOCkOf1jgWVWx9L8mLdFoKM5lBRmvpANq0D8oULPqNqHKMTjZMRafKl9segDZjd4gHx+cHT+QRHfw==

req.xhr

TVT8ciczgyL/aHiQaL7uYuv6tWh+30zI1RB4R1DBjsNlPd0gR5QtBikHFuJbLTB78XYWiXWMLOnxgmmGz86Ebl/gcR0x7/fuB6aOtFp9GvUnzKB1q1ym4EAJVBckRT048grfmRsgW18Ns772hvB9gbq7fb4StetXDfE5N1XDFstV+OCX8335VnPv11PIoK2qM6EcNgIT6HlpG7o/g7BwoZmfe567qIiae0VxHwnLhTGlmlfKX8px9CZPCS6413GW

console.dir(req.xhr)
// => true

req.accepts(types)

cD7gDkor3TG++WgEHxoc/hYtDnQp9igLS94exRuYr/wauq8JjvKrlXveU2rJ5xapzs17MV75BSAZ7elhsc30NQm62ovx3SxyzJy8QH1WxdJhT5/HOB4yygNRhJs//S+lLUz7Val4adD52sFkJuWc2HDB39tHEt5eP+Hc6goOwOFrtP/Gurbz4AS07aJ9Wv/llN5wNe/TQPb+TpYcxG+Thph63OeKRGc4pkq6YgGk/CCviwrsHXA01L04qdqmT0kAN2ZOTKZ1IKY/smw8QsHgIsLajNxFH/22f4UEtdXY8xudJAZFzmvEN+bX6X+ZZvFB2ARgGb8v2gVkAW2TJCOR7FUUb6w6bA8v7WR+8TqOa8q0fiOBwQRaquCZIPj70fSWlNgjyc9U8xEOqnF9sbt9fw==

KgX2FNZy2CgemGmp0FiQ8TXR66j/xenfNyUbwBFelyWuf/QYyMXTQ53WArevomZn2ZELFhpe6rfp4V7J9ej+VhnOwLWjkTmsJ9RWuUg6UdzGJ4CKswUAqmp/mL8GPy1pA7M2ZYnWn0BwOU7AxrZ8AEQPXtUfD0Ndvi3tKumVDZca/ydJR9kms2sfbjM21pn7FVdqsVxUnE0Rw2Y38qMC4B9giMqoFMgfDeTL36/h3UOx0MvoCCxC4Jt4i4Ni5GKHmXTLJHMq5k7AQOXX9RMA5WGp01mTee1e5WDJdlmTPIk/VZj/LF+jJ5L/LB89+iQt

// Accept: text/html
req.accepts('html')
// => "html"

// Accept: text/*, application/json
req.accepts('html')
// => "html"
req.accepts('text/html')
// => "text/html"
req.accepts(['json', 'text'])
// => "json"
req.accepts('application/json')
// => "application/json"

// Accept: text/*, application/json
req.accepts('image/png')
req.accepts('png')
// => false

// Accept: text/*;q=.5, application/json
req.accepts(['html', 'json'])
// => "json"

i5mH/polGS/9PLtgcrAy2vyzhQztu97ADJUyNEshuw3pSP9tk3OqdCBesgaJAdHl54nkjZ86A59NebvjLMuHwtnoqPCdD2SzSMG7LWryMcPr3IKxYntNZJYdKcYWoPiTiketin/JtpgB3RY+b4B/QmH/nDhzVg+NYez/sfIUdak=

req.acceptsCharsets(charset [, ...])

cD7gDkor3TG++WgEHxoc/sN1NsXHOu6LzGxtZaugFBJY/+KqQ14RbK1V/DEYKs4tGVmt0o2u+tkDtKTkyEi1m8MI4KJ7e3ped3fqmfD9ECbG+oLaFiyk7E8/lxi8gpIMNCmqzjpaLr7tjbrdsfXmIbMFqsO1MfU9NA32qa/FM8jiOPuugj35yIc66tM1HIcWTXmOBY8Pmw8qLJicSbKlDYS2j/RHUBj6dqyNbbYhco4caBIxH1lN3Ykv+YLTch7U

i5mH/polGS/9PLtgcrAy2vyzhQztu97ADJUyNEshuw3pSP9tk3OqdCBesgaJAdHl54nkjZ86A59NebvjLMuHwtnoqPCdD2SzSMG7LWryMcPr3IKxYntNZJYdKcYWoPiTiketin/JtpgB3RY+b4B/QmH/nDhzVg+NYez/sfIUdak=

req.acceptsEncodings(encoding [, ...])

cD7gDkor3TG++WgEHxoc/njgGvNtP8whLyUzz0EopoOnHFoiIysk8CfCOyi+bkic4Tm3gjTqkRQxzl4SA6olf764VW83jdqXv9wsZepARLmVxOp2KG1woW1O8saDHZF8lf36WbokBBMiCgUnKHHgLykK/xey+CPUa+DkYEC4W0TVs8wCp/14Xsgs5sX3t8gjKDhROiARjAkoRX4cHHEqIWXZkAyx6HD+nDOSMLn7cMMwk+KDqEWHuXUIJ5CKhTrQ

i5mH/polGS/9PLtgcrAy2vyzhQztu97ADJUyNEshuw3pSP9tk3OqdCBesgaJAdHl54nkjZ86A59NebvjLMuHwtnoqPCdD2SzSMG7LWryMcPr3IKxYntNZJYdKcYWoPiTiketin/JtpgB3RY+b4B/QmH/nDhzVg+NYez/sfIUdak=

req.acceptsLanguages(lang [, ...])

cD7gDkor3TG++WgEHxoc/m/AD8ct5tLfqlyiA02ncFx5V93yYMA8Jzsib6xhBNa4owZUvLK6slOE3N/evYl0qVmm22o2eab1ymaB/NUBD5xWyqo3c8j7Ymf1DUjuV2EBwll77QChmWgwXw6KsCqWnleh2ocWiNmskp6nT7RBSD2jBFPgxxm2ZeQIRSDdqZHRbqY+srxJgDlc7lg5MGRKGMc62g2Rk58GjAYSla+cAsUlvo5FT9970zbMfssSx37i

i5mH/polGS/9PLtgcrAy2vyzhQztu97ADJUyNEshuw3pSP9tk3OqdCBesgaJAdHl54nkjZ86A59NebvjLMuHwtnoqPCdD2SzSMG7LWryMcPr3IKxYntNZJYdKcYWoPiTiketin/JtpgB3RY+b4B/QmH/nDhzVg+NYez/sfIUdak=

req.get(field)

DDrHS6idc1uQdV8dy1scJjwJRc1H1nDuLotF3exMjVVewCuC5m3XRPsNoj1rhUT0whfjkF2Ok93dstsITmDFKYblzRcM6nRVIZDXdL2fCQYan4R3E5+UT2eupBFZXYHTH7hF9fr8b5VubztCkT8AdHDd1Imd34BuTJrJybLw4HPjHvohFZ6+RUggGHWVnLZ9

req.get('Content-Type')
// => "text/plain"

req.get('content-type')
// => "text/plain"

req.get('Something')
// => undefined

wRyUjsLDVE8WOzo7+RSrXK7drHUDS5nGqG1QAlZ7G4t4pcnyaMPvCZOsrNjtemqA

req.is(type)

HgqMU3Zu6GrJn624mUGy6ni0jSS6Fw3wCdU0uHXGJ/KuIufgaulSYzlku8tLCjYEC2lqkUDn3YH+clEt2TzSiym+MUXPAqxcEAzFwcngOeeuh4z2+JQmezB++bsHZvgxwoB+zNCOyYI2UsHXtHbxa8z5Jpie6xwD+LJIRmVLukILvUaS/eR4Y+VqY0nvXo0u8kyXxz2XBUBO/nMrzw8fs3Sjsf6je+ubkQlQjibnP4r5MjcJRM8y+v3utTP8mKccWlVVDPJcOtjGDFCJutRmRt69CUgWmMlL7GpjRV91eWrm3eoQN1wOxNC5ekfPN5ou

// With Content-Type: text/html; charset=utf-8
req.is('html')
// => 'html'
req.is('text/html')
// => 'text/html'
req.is('text/*')
// => 'text/*'

// When Content-Type is application/json
req.is('json')
// => 'json'
req.is('application/json')
// => 'application/json'
req.is('application/*')
// => 'application/*'

req.is('html')
// => false

i5mH/polGS/9PLtgcrAy2vyzhQztu97ADJUyNEshuw3pSP9tk3OqdCBesgaJAdHl54nkjZ86A59NebvjLMuHwnjlLsvO+aNtr/cU0X7a5+rvw3Prx6Y/YrW0vvd/WK2c6EXE9NrSupWS3fpWtKw1Xtg3hYLKvT9HKPai+1TMjq8=

req.param(name [, defaultValue])

zIGPWW7ryze294e93haUeUvRA99QQ5rqkI51DWWQIR8RIbh18RaANdOxQ7KaGHPpswxARlqk0SF615yyRUanT1fbol8JOePfE63TXZls5j9pYcS0+kZ+BIUr5k4anGvqTSYMABv4i/HTXbnKtELfNw==

TBUiuLJxa1HPctaYvoCD7AC4BUy7cG5T2P8FHgXHAYYw47Albo9nnJ7cGBaC9QOe6lXExMUT+59HpSqomOpHrA==

// ?name=tobi
req.param('name')
// => "tobi"

// POST name=tobi
req.param('name')
// => "tobi"

// /user/tobi for /user/:name
req.param('name')
// => "tobi"

OviPVSTARFRbYeRCITnogQ2/4SX4QaZFzZFtv9dVnbY=

    Rne1V6Xw6J8REZWLIhgG0TuOLkS8i4+Z+0tQ5aV7sL7mUnHVcKf8kh2dR/BgudXzkJ28SlshvScMkHJBtFx03jBQlaicOok7c4IdZYihqRoiq3rTQ6irf3PwpRxxpLt9HfEaYMiF0qNPhKvRuEfGkA==

yk37/JmIUL2r4gX0sZcHSymA6aQbnFpxIJV9yk0UwQhdzVLZ5A7yZHKGV3YiV2OHSLoKlfJzgeolQVkckdp9NxhcU89YkiUMC5cSmlLffE1NETyStYQ8fUSISAmWnywIraKPm4h6mmrQKADGg+77DzcjeiwFZD5e4LFfVEmdnTg=

wkwfT3BPMQ5S+xq9LZ5GLbI/8JyQ7qxeGnj1gszSP2vKkzsP8qe4bkJm64f+fy+AXls35N/ItcNexNQdyIxSm63vNJKi+E4JorPrajoRTGifhICBZ5FU9B/WheZUplOezahXVr9nmcDc/mxw49I1ly0vuyAOt7irLwyBVJiwp2wnl75VzMMJtXWmANwueRBZjEDfBO81bq8cWccF2HG8KNFfsXxqxBEXm/6phNmlYmQ=

1SBsIvF6U3PQYR6K9WEamH5NZdEPJWO2VVv8HeDJfFxJMLsqgHEhte5qfsobJ95hxGoG6CuGQPOGPayKPPfb28wc0Z8ieD/pvCXTkjoB7DJ0eXJrqeofxmz/hxeOdZ8Z+2cmNXLXoFboyEZn8iC8iXsq0s5jGm/DOQB2eQ1FMPTQLBejy+kC3LEvggYcR/4VY5dE3jkZABC0HJixBO+f9548GaEezGBp9j5EQbtXMuo=

req.range(size[, options])

eUCwoB3pVYyzlam+XzWNG4+5P3X+4eM195VsrWg9YVFJ9CAPnpSV08cCrtE9zy2f

IYTTHrEzZpsVo1CmUlHnSvuUYJ5B7xFFWv6dfJDEnTIKkeYcbGIUzS9PP1l+KSSS9wem3+j4/oTKaMgyHfr7Cg==

MgO71yypnOaPB2lZbuh367cVTn/kf2wiFjadRW0QZie3z4xyBRy1hz3nb/hvwobWaZi7wzpxuCK+IMG7THg0yBKhZXHI+FKVEhSP4KTwgqA=

属性类型描述
combine布尔值指定是否应合并重叠和相邻范围,默认为 false。当 true 时,范围将被组合并返回,就好像它们在标题中以这种方式指定一样。

JqaF53yvaUqUb9txDrhTZ4u55UUqtDEsSCH/3aXnuzfbTsxZBBVmFcWV+YsbieWEGyoNeSuyPEErcavyZtjTrg==

    SdtQvIq+iG6Yjjw0J6XunbSV3d7+p+I4koa/24wbtYT8gfR8zxmNYka+H5vf5fFEFbyARz/jei8RCB2FImcriaBpyAPIps+QPK0+UvUXMXiJoG2j17FJpmdqxWMAprqtyy7tAYbbdqO66uCo6hskZ5M5rH5Tw4TMhORmW7ohsyM=
// parse header from request
var range = req.range(1000)

// the type of the range
if (range.type === 'bytes') {
  // the ranges
  range.forEach(function (r) {
    // do something with r.start and r.end
  })
}