post form ,$request_uri nginx-cache
//userMac 是 String 用户终端Mac
//sn 否 String wifi设备SN
//adTypeId 是 Integer 广告类别Id '1':'展示类广告' '2':'视频贴片类广告'
//adPositionId 是 Integer 广告位id '1': '首页插屏' '2': '首页banner' '3': '首页底部浮层' '4': '频道页banner' '5': '自弹页全屏' '6': '自弹页半屏' '7': '外网劫持' '8': '首页红包浮层' '9': '自弹页红包浮层'
//channelId 否 Integer 频道Id '1': '电影' '2': '综艺' '3': '在线游戏' '4': '游戏下载'
function getADCachePush(sn, adTypeId, adPositionId, channelId) {
let form = frisby.formData();
form.append("sn", sn)
form.append("adTypeId", adTypeId)
form.append("adPositionId", adPositionId)
form.append("channelId", channelId)
//console.log("user-agent", uastr)
// adCacheServer : http://....
console.log("form", form)
return new Promise(resolve => {
return frisby.post(adCacheServer, {
body: form
})
.expect("status", 200)
.then(res => {
//console.log(res)
// console.log(res.headers)
//console.log("adPushResult", res.json);
resolve(res);
})
})
}
form data FormData {
_overheadLength: 427,
_valueLength: 2,
_valuesToMeasure: [],
writable: false,
readable: true,
dataSize: 0,
maxDataSize: 2097152,
pauseStreams: true,
_released: false,
_streams:
[ '----------------------------125081902639415250405831\r\nContent-Disposition: form-data; name="sn"\r\n\r\n',
'',
[Function: bound ],
'----------------------------125081902639415250405831\r\nContent-Disposition: form-data; name="adTypeId"\r\n\r\n',
'1',
[Function: bound ],
'----------------------------125081902639415250405831\r\nContent-Disposition: form-data; name="adPositionId"\r\n\r\n',
'1',
[Function: bound ],
'----------------------------125081902639415250405831\r\nContent-Disposition: form-data; name="channelId"\r\n\r\n',
'',
[Function: bound ] ],
_currentStream: null,
_boundary: '--------------------------125081902639415250405831' }
//sn 否 String wifi设备SN
//adTypeId 是 Integer 广告类别Id '1':'展示类广告' '2':'视频贴片类广告'
//adPositionId 是 Integer 广告位id '1': '首页插屏' '2': '首页banner' '3': '首页底部浮层' '4': '频道页banner' '5': '自弹页全屏' '6': '自弹页半屏' '7': '外网劫持' '8': '首页红包浮层' '9': '自弹页红包浮层'
//channelId 否 Integer 频道Id '1': '电影' '2': '综艺' '3': '在线游戏' '4': '游戏下载'
function getADCachePush(sn, adTypeId, adPositionId, channelId) {
return new Promise(resolve => {
return frisby.post(adCacheServer, {
body: `sn=${sn}&adTypeId=${adTypeId}&adPositionId=${adPositionId}&channelId=${channelId}`
})
.expect("status", 200)
.then(res => {
//console.log(res)
console.log("res.headers", res.headers)
//console.log("adPushResult", res.json);
resolve(res);
})
})
}
// 测试示例:
fit("simple test",function(done){
getADCachePush("", 1, 1, "").then((res) => {
console.log("getADCachePush (1)", res.json);
setTimeout(() => {
getADCachePush("", 1, 1, "").then((res) => {
console.log("getADCachePush (2)", res.json);
done();
})
}, 1000);
})
})
命中结果:
onsole.log Spec\cpsPlanSpec.js:1922
res.headers Headers {
_headers:
{ server: [ 'nginx/1.7.10' ],
date: [ 'Wed, 14 Mar 2018 10:04:36 GMT' ],
'content-type': [ 'application/json;charset=UTF-8' ],
'transfer-encoding': [ 'chunked' ],
connection: [ 'close' ],
'access-control-allow-origin': [ '*' ],
'access-control-allow-methods': [ '*' ],
'access-control-max-age': [ '100' ],
'access-control-allow-headers': [ 'Content-Type' ],
'access-control-allow-credentials': [ 'false' ],
pragma: [ 'no-cache' ],
expires: [ 'Thu, 01 Jan 1970 00:00:00 GMT' ],
'cache-control': [ 'no-cache, no-store' ],
'nginx-cache': [ 'HIT' ] } }
server {
location ~* /media-ad/ {
default_type text/html;
rewrite ^/media-ad/(.*)/(.*) /$1/api/advertise/cache break;
proxy_pass https://139.219.99.153;
proxy_cache media_cache;
proxy_cache_valid 200 1h;
proxy_cache_methods POST;
proxy_cache_key "$request_uri|$request_body";
proxy_ignore_client_abort on;
proxy_cache_lock on;
proxy_cache_lock_timeout 60s;
add_header Nginx-Cache "$upstream_cache_status";
}
}
附2,nginx中有几个关于uri的变量的区别
--【引用地址】https://www.cnblogs.com/JohnABC/p/6182826.html