第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何使用nodejs http API模擬web form表單提交?

如何使用nodejs http API模擬web form表單提交?

www說 2019-04-10 20:48:01
現(xiàn)在一個(gè)應(yīng)用需要訪問不同域下的TAM安全認(rèn)證服務(wù),需要模擬form表單提交到WebSEAL,先謝謝了。以下是我目前嘗試的http請(qǐng)求寫法:varhttp=require('http');varquerystring=require('querystring');varpost_options={host:'192.168.1.22',port:'80',path:'/pkmslogin.form',method:'post',auth:'username:123456','login-form-type':'pwd',headers:{'Content-Type':'application/x-www-form-urlencoded'}};varpost_data=querystring.stringify({username:'username',password:'123456','login-form-type':'pwd'});//Setuptherequestvarpost_req=http.request(post_options,function(res){res.setEncoding('utf8');console.log(JSON.stringify(res.headers));res.on('data',function(chunk){console.log('Response:'+chunk);});});console.log(JSON.stringify(post_req.headers));//postthedata//post_req.write(post_data);post_req.end();
查看完整描述

2 回答

?
神不在的星期二

TA貢獻(xiàn)1963條經(jīng)驗(yàn) 獲得超6個(gè)贊

還需注意以下兩點(diǎn):
//1、在頭中設(shè)置好內(nèi)容長(zhǎng)度
headers:{
'Content-length':post_data.length,
'Content-Type':'application/x-www-form-urlencoded'
}
varpost_data=querystring.stringify({
username:'username',
password:'123456',
'login-form-type':'pwd'
});
//2、參數(shù)寫入到流中
post_req.write(post_data);
                            
查看完整回答
反對(duì) 回復(fù) 2019-04-10
  • 2 回答
  • 0 關(guān)注
  • 355 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)