1. 程式人生 > >Nodejs之request 和 response 物件的具體介紹

Nodejs之request 和 response 物件的具體介紹

  1. res.app:同req.app一樣
  2. res.append():追加指定HTTP頭
  3. res.set()在res.append()後將重置之前設定的頭
  4. res.cookie(name,value [,option]):設定Cookie
  5. opition: domain / expires / httpOnly / maxAge / path / secure / signed
  6. res.clearCookie():清除Cookie
  7. res.download():傳送指定路徑的檔案
  8. res.get():返回指定的HTTP頭
  9. res.json():傳送JSON響應
  10. res.jsonp():傳送JSONP響應
  11. res.location():只設置響應的Location HTTP頭,不設定狀態碼或者close response
  12. res.redirect():設定響應的Location HTTP頭,並且設定狀態碼302
  13. res.send():傳送HTTP響應
  14. res.sendFile(path [,options] [,fn]):傳送指定路徑的檔案 -會自動根據檔案extension設定Content-Type
  15. res.set():設定HTTP頭,傳入object可以一次設定多個頭
  16. res.status():設定HTTP狀態碼
  17. res.type():設定Content-Type的MIME型別