向chai请求添加自定义http标头

时间:2016-04-30 23:06:27

标签: node.js testing request chai

我正在使用node.js构建应用程序并使用mocha + chai进行测试。有没有办法可以为我的GET和POST chai请求添加自定义标题?

例如,我想要(半伪代码):

chai.request(server)
  .get('/api/car/' + data.car_id)
  .headers({'some_custom_attribute':'some_value'})
  .end(function(err, res) {
    //do something
  });

同样有帖子:

chai.request(server)
  .post('/api/car/')
  .headers({'some_custom_attribute':'some_value'})
  .send({car_id: 'some_car_id'})
  .end(function(err, res) {
    //do something
  });

有人可以帮忙吗?

提前致谢!

1 个答案:

答案 0 :(得分:30)

使用 $_hsync_konekcija->query("INSERT INTO $_hsync_usr ( Ime, ID, Registriran, Zaporka, ZaporkaMD5, IP, GPCI, Mail, Spol, Godine, Skin, MailNotf, Datum, Vrijeme, Visina, OstalaMasa, MisicnaMasa, MasaSala, Zeludac, Metabolizam, PotrebaH2O, Opijanje, Drogiranje, Udarac, RastDlaka, hEx) VALUES ( '$_hsync_ime', $_hsync_id, $_hsync_reg, 'nista', '$_hsync_zaporka_hash', 'nista', 'nista', '$_hsync_mail', $_hsync_spol, $_hsync_godine, $_hsync_skin, $_hsync_mail_notf, '$_hsync_datum', '$_hsync_vrijeme', $_hsync_visina, $_hsync_omasa, $_hsync_mmasa, $_hsync_msala, $_hsync_zeludac, $_hsync_metabolizam, $_hsync_potrebah2o, $_hsync_opijanje, $_hsync_drogiranje, $_hsync_udarac, $_hsync_rastdlaka, $_hsync_hEx)"); 功能设置http标头:

set

setting-up-requests