loadrunner上传文件到网盘
有人提问,loadrunner 上传文件搞不好,请求帮忙处理。让提供网址,用fiddler抓包上传部分,主要有3个请求
第一个请求
GET https://yun.xxx.com/api/files/upload/request?groupid=406896460&parentid=0&size=10&name=ae.txt&parent_path=&checkname=true&store=ks3&method=POST HTTP/1.1
Host: yun.xxx.com
Connection: keep-alive
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36
Accept: */*
Referer: https://yun.xxx.com/drive/group/406896460
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Cookie: sajssdk_2015_cross_new_user=1; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%22164ede8841f339-032750c7b54867-68151275-1049088-164ede88421341%22%2C%22%24device_id%22%3A%22164ede8841f339-032750c7b54867-68151275-1049088-164ede88421341%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_referrer%22%3A%22%22%2C%22%24latest_referrer_host%22%3A%22%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%7D%7D; Hm_lvt_088d7d4ca9fd9c419f6d37e55a2732bb=1532999796; xabqing_autoLoginV1=1; numberOfFailedAttempts=0; xab_sid=V02S4fptWYKB4Yj7C3WnpOkUVibg77Y01475a7a40016f157e9; csrf=weWzjjrbf2AB3cs2wwBBkCCCtA3Dk4BZ; domain=xxx.com
响应:
HTTP/1.1 200 OK
Server: CLOUD ELB 1.0.0
Date: Tue, 31 Jul 2018 08:47:24 GMT
Content-Type: application/json;charset=utf-8
Content-Length: 535
Connection: keep-alive
Expires: Thu, 01 Jan 1970 00:00:01 GMT
Cache-Control: no-cache
Cache-Control: no-store
{"KSSAccessKeyId":"1GL02rRYQxK8s7FQh8dV","Policy":"eyJleHBpcmF0aW9uIjoiMjAxOC0wNy0zMVQwOToxNzoyNC4wMDBaIiwiY29uZGl0aW9ucyI6W3sia2V5IjoidGVtcF8zODQ5MTU0MzNfYjcwMTI2ODRlMTQ4NDMyY2FmN2MwNjk1MTQ0ZDdkNTEifSx7ImJ1Y2tldCI6Indwc2ZpbGUifSx7Ingta3NzLW5ld2ZpbGVuYW1lLWluLWJvZHkiOnRydWV9XX0=","Signature":"/NrpuemYa4Pn0+DXkd81It/bLEo=","exist_fname":false,"fname":"ae.txt","key":"temp_384915433_b7012684e148432caf7c0695144d7d51","result":"ok","stat":"OK","store":"ks3","url":"https://zhstorage.yun.xxx.com/xabfile","x-kss-newfilename-in-body":true}
第二个请求:
POST https://zhstorage.yun.xxx.com/xabfile HTTP/1.1
Host: zhstorage.yun.xxx.com
Connection: keep-alive
Content-Length: 1009
Origin: https://yun.xxx.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryQKcfp7lhPEaqB3Td
Accept: */*
Referer: https://yun.xxx.com/drive/group/406896460
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
------WebKitFormBoundaryQKcfp7lhPEaqB3Td
Content-Disposition: form-data; name="key"
temp_384915433_b7012684e148432caf7c0695144d7d51
------WebKitFormBoundaryQKcfp7lhPEaqB3Td
Content-Disposition: form-data; name="Signature"
/NrpuemYa4Pn0+DXkd81It/bLEo=
------WebKitFormBoundaryQKcfp7lhPEaqB3Td
Content-Disposition: form-data; name="KSSAccessKeyId"
1GL02rRYQxK8s7FQh8dV
------WebKitFormBoundaryQKcfp7lhPEaqB3Td
Content-Disposition: form-data; name="Policy"
eyJleHBpcmF0aW9uIjoiMjAxOC0wNy0zMVQwOToxNzoyNC4wMDBaIiwiY29uZGl0aW9ucyI6W3sia2V5IjoidGVtcF8zODQ5MTU0MzNfYjcwMTI2ODRlMTQ4NDMyY2FmN2MwNjk1MTQ0ZDdkNTEifSx7ImJ1Y2tldCI6Indwc2ZpbGUifSx7Ingta3NzLW5ld2ZpbGVuYW1lLWluLWJvZHkiOnRydWV9XX0=
------WebKitFormBoundaryQKcfp7lhPEaqB3Td
Content-Disposition: form-data; name="x-kss-newfilename-in-body"
true
------WebKitFormBoundaryQKcfp7lhPEaqB3Td
Content-Disposition: form-data; name="file"; filename="ae.txt"
Content-Type: text/plain
aaaaaaaaac
------WebKitFormBoundaryQKcfp7lhPEaqB3Td--
响应:
HTTP/1.1 200 OK
Server: nginx/1.13.3
Date: Tue, 31 Jul 2018 08:47:25 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 59
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Expose-Headers: newfilename, x-kss-request-id, ETag, Date
Etag: 795d01e0360ef19b3a41ed915443f7c1
Newfilename: ba9da2b1a0584bfc36ef0e5c0007ec3f03913a81
Vary: Origin
X-Kss-Request-Id: 296b72bb-dca6-4c0a-8f1f-b5e921e9051e
{"newfilename":"ba9da2b1a0584bfc36ef0e5c0007ec3f03913a81"}
第三个请求:
POST https://yun.xxx.com/api/v3/groups/406896460/files?im_push=1&store=ks3&action= HTTP/1.1
Host: yun.xxx.com
Connection: keep-alive
Content-Length: 203
Origin: https://yun.xxx.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36
Content-Type: application/json
Accept: */*
Referer: https://yun.xxx.com/drive/group/406896460
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9
Cookie: sajssdk_2015_cross_new_user=1; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%22164ede8841f339-032750c7b54867-68151275-1049088-164ede88421341%22%2C%22%24device_id%22%3A%22164ede8841f339-032750c7b54867-68151275-1049088-164ede88421341%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_referrer%22%3A%22%22%2C%22%24latest_referrer_host%22%3A%22%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%7D%7D; Hm_lvt_088d7d4ca9fd9c419f6d37e55a2732bb=1532999796; xabqing_autoLoginV1=1; numberOfFailedAttempts=0; xab_sid=V02S4fptWYKB4Yj7C3WnpOkUVibg77Y01475a7a40016f157e9; csrf=weWzjjrbf2AB3cs2wwBBkCCCtA3Dk4BZ; domain=xxx.com
{"groupid":"406896460","parentid":0,"parent_path":[],"name":"ae.txt","secure_guid":"","size":10,"sha1":"ba9da2b1a0584bfc36ef0e5c0007ec3f03913a81","csrfmiddlewaretoken":"weWzjjrbf2AB3cs2wwBBkCCCtA3Dk4BZ"}
响应:
HTTP/1.1 200 OK
Server: CLOUD ELB 1.0.0
Date: Tue, 31 Jul 2018 08:47:26 GMT
Content-Type: application/json;charset=utf-8
Content-Length: 712
Connection: keep-alive
Access-Control-Allow-Credentials: true
Access-Control-Allow-Headers: Accept,Content-Type
Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS
Access-Control-Allow-Origin: https://yun.xxx.com
Access-Control-Expose-Headers: Accept,Content-Type
X-QReqID: 15330268463565160510584
Cache-Control: no-store
{"id":11329694092,"fileid":11329694092,"groupid":406896460,"parentid":0,"fname":"ae.txt","ftype":"sharefile","fver":1,"fsize":10,"fsha":"ba9da2b1a0584bfc36ef0e5c0007ec3f03913a81","storeid":"","store":9,"secure_guid":"","deleted":false,"ctime":1533026846,"mtime":1533026846,"creator":{"id":384915433,"name":"张三丰","avatar":"https://avatar.qxxx.com/avatar/546L5b636LaF"},"modifier":{"id":384915433,"name":"张三丰","avatar":"https://avatar.qxxx.com/avatar/546L5b636LaF"},"user_acl":{"copy":1,"delete":1,"download":1,"history":1,"move":1,"new_empty":0,"read":1,"rename":1,"secret":1,"share":1,"update":1,"upload":0},"node":0,"storage_host":"zhstorage.yun.xxx.com","preview_host":"zhvdoc.yun.xxx.com","tags":null}
分析请求,请求中的cookie,是从登陆中获取到的,由于是帮忙,并且环境无法录制,就直接用web_add_cookie 来让脚本免登陆。第一个请求后会返回一些数据,这些数据要用在第二个请求中,这就需要用关联。同样,第二个请求的响应也返回一些数据,用到第三个请求中。第三个请求发送完毕,上传完成
lr脚本如下:
Action()
{
lr_save_string("ae.txt","filename");
lr_save_string("weWzjjrbf2AB3cs2wwBBkCCCtA3Dk4BZ","csrf");
web_add_cookie("sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%22164ede8841f339-032750c7b54867-68151275-1049088-164ede88421341%22%2C%22%24device_id%22%3A%22164ede8841f339-032750c7b54867-68151275-1049088-164ede88421341%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_referrer%22%3A%22%22%2C%22%24latest_referrer_host%22%3A%22%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%7D%7D; DOMAIN=yun.xxx.com");
web_add_cookie("sajssdk_2015_cross_new_user=1; DOMAIN=yun.xxx.com");
web_add_cookie("Hm_lvt_088d7d4ca9fd9c419f6d37e55a2732bb=1532999796; DOMAIN=yun.xxx.com");
web_add_cookie("xabqing_autoLoginV1=1; DOMAIN=yun.xxx.com");
web_add_cookie("numberOfFailedAttempts=0; DOMAIN=yun.xxx.com");
web_add_cookie("xab_sid=V02S4fptWYKB4Yj7C3WnpOkUVibg77Y01475a7a40016f157e9; DOMAIN=yun.xxx.com"); //{"KSSAccessKeyId":"1GL02rRYQxK8s7FQh8dV","Policy":"eyJleHBpcmF0aW9uIjoiMjAxOC0wNy0zMVQwNzoyNzoxMy4wMDBaIiwiY29uZGl0aW9ucyI6W3sia2V5IjoidGVtcF8zODQ5MTU0MzNfNTFiZWJhMTZkZDBkNDVlNGJlODQ4MDI4OTBhZTY0ZGEifSx7ImJ1Y2tldCI6Indwc2ZpbGUifSx7Ingta3NzLW5ld2ZpbGVuYW1lLWluLWJvZHkiOnRydWV9XX0=","Signature":"1FR73bqB8UtFdq30KYavSgS6XZg=","exist_fname":false,"fname":"aa.txt","key":"temp_384915433_51beba16dd0d45e4be84802890ae64da","result":"ok","stat":"OK","store":"ks3","url":"https://zhstorage.yun.xxx.com/xabfile", "x-kss-newfilename-in-body":true} web_reg_save_param("KSSAccessKeyId","LB=KSSAccessKeyId\":\"", "RB=\"", LAST);
web_reg_save_param("Policy", "LB=Policy\":\"", "RB=\"", LAST);
web_reg_save_param("Signature", "LB=Signature\":\"", "RB=\"", LAST);
web_reg_save_param("key", "LB=key\":\"", "RB=\"", LAST);
//web_reg_save_param("x-kss-newfilename-in-body", "LB=x-kss-newfilename-in-body\":\"", "RB=\}", LAST);
web_reg_save_param("x-kss-newfilename-in-body", "LB=x-kss-newfilename-in-body\"\:", "RB=\}", LAST); web_url("request",
"URL=https://yun.xxx.com/api/files/upload/request?groupid=406896460&parentid=0&size=10&name=aa.txt&parent_path=&checkname=true&store=ks3&method=POST",
"Resource=1",
"RecContentType=application/json",
"Referer=https://yun.xxx.com/drive/group/406896460",
"Snapshot=t20.inf",
LAST); web_add_auto_header("User-Agent",
"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"); web_add_header("Content-Type",
"application/json;charset=utf-8"); // web_add_auto_header("Content-Type","multipart/form-data");
web_add_header("Accept-Encoding",
"gzip, deflate"); web_reg_save_param("newfilename","LB=newfilename\":\"", "RB=\"}", LAST);
web_submit_data("xabfile",
"Action=https://zhstorage.yun.xxx.com/xabfile",
"Method=POST",
"EncType=multipart/form-data",
"RecContentType=text/plain",
"Referer=http://yun.xxx.com/drive/group/406896460",
"Snapshot=t21.inf",
"Mode=HTTP",
ITEMDATA,
"Name=key", "Value={key}", ENDITEM,
"Name=Signature", "Value={Signature}", ENDITEM,
"Name=KSSAccessKeyId", "Value={KSSAccessKeyId}", ENDITEM,
"Name=Policy", "Value={Policy}", ENDITEM,
"Name=x-kss-newfilename-in-body", "Value={x-kss-newfilename-in-body}", ENDITEM,
"Name=file", "Value=C:/{filename}", "File=Yes", ENDITEM,
LAST);
web_add_header("Origin", "https://yun.xxx.com");
lr_save_string("","id");
web_custom_request("files_3",
"URL=https://yun.xxx.com/api/v3/groups/{id}/files?im_push=1&store=ks3&action=",
"Method=POST",
"Resource=0",
"RecContentType=application/json",
"Referer=https://yun.xxx.com/drive/group/{id}",
"Snapshot=t22.inf",
"Mode=HTTP",
"EncType=application/json; charset=UTF-8",
"Body={\"groupid\":\"{id}\",\"parentid\":0,\"parent_path\":[],\"name\":\"{filename}1\",\"secure_guid\":\"\",\"size\":10,\"sha1\":\"{newfilename}\",\"csrfmiddlewaretoken\":\"{csrf}\"}",
LAST); return ;
}
代码解析:
web_add_cookie 添加cookie 从而暂时免登录
web_add_cookie("sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%22164ede8841f339-032750c7b54867-68151275-1049088-164ede88421341%22%2C%22%24device_id%22%3A%22164ede8841f339-032750c7b54867-68151275-1049088-164ede88421341%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_referrer%22%3A%22%22%2C%22%24latest_referrer_host%22%3A%22%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%7D%7D; DOMAIN=yun.xxx.com");
web_add_cookie("sajssdk_2015_cross_new_user=1; DOMAIN=yun.xxx.com");
web_add_cookie("Hm_lvt_088d7d4ca9fd9c419f6d37e55a2732bb=1532999796; DOMAIN=yun.xxx.com");
web_add_cookie("xabqing_autoLoginV1=1; DOMAIN=yun.xxx.com");
web_add_cookie("numberOfFailedAttempts=0; DOMAIN=yun.xxx.com");
web_add_cookie("xab_sid=V02S4fptWYKB4Yj7C3WnpOkUVibg77Y01475a7a40016f157e9; DOMAIN=yun.xxx.com");
关联获取第一个请求返回需要的信息
web_reg_save_param("KSSAccessKeyId","LB=KSSAccessKeyId\":\"", "RB=\"", LAST);
web_reg_save_param("Policy", "LB=Policy\":\"", "RB=\"", LAST);
web_reg_save_param("Signature", "LB=Signature\":\"", "RB=\"", LAST);
web_reg_save_param("key", "LB=key\":\"", "RB=\"", LAST);
//web_reg_save_param("x-kss-newfilename-in-body", "LB=x-kss-newfilename-in-body\":\"", "RB=\}", LAST);
web_reg_save_param("x-kss-newfilename-in-body", "LB=x-kss-newfilename-in-body\"\:", "RB=\}", LAST);
在做脚本时,第三个请求老是不成功,把脚本发送的请求和手动上传的请求对比,发现正常的请求有一行header请求
Origin: https://yun.xxx.cn
于是添加一行lr代码:
web_add_header("Origin", "https://yun.xxx.com");
最后,代码运行通过,上传成功
loadrunner上传文件到网盘的更多相关文章
- Loadrunner上传文件解决办法(大文件)
Loadrunner上传文件解决办法(大文件) 最近再做一个跟海量存储相关的项目测试,需要通过LR模拟用户大量上传和下载文件,请求是Rest或Soap,同时还要模拟多种大小尺寸不一的文件 通常情况下, ...
- Loadrunner上传文件与下载文件脚本
Loadrunner上传文件与下载文件脚本 一. 上传脚本 Action() { int uploadImgStatus = 0; //获取上传产品图ID web_reg_save_param_ex( ...
- 转:Loadrunner上传文件解决办法(大文件)
最近再做一个跟海量存储相关的项目测试,需要通过LR模拟用户大量上传和下载文件,请求是Rest或Soap,同时还要模拟多种大小尺寸不一的文件 通常情况下,都是使用简单的post协议即可: 方法一: we ...
- ubuntu上传到百度网盘
1 2 亲测可以上传
- LoadRunner上传文件脚本
- LoadRunner上传及下载文件
(1)LoadRunner上传文件 web_submit_data("importStudent.do", "Action=https://testserver/cons ...
- 【Loadrunner】使用LoadRunner上传及下载文件
使用LoadRunner上传及下载文件 1)LoadRunner上传文件 web_submit_data("importStudent.do", "Action=http ...
- loadrunner 上传下载
转http://blog.163.com/yings_9371/blog/static/66196922010711115545137/ (1)LoadRunner上传文件 web_submit_da ...
- Linux命令行上传文件到百度网盘
利用bpcs_uploader你可以自动将VPS主机上的文件上传到百度网盘中,同时也可以从百度网盘中下载文件到VPS主机上,让你的文件安全地"住"在百度云中.[font=Tahom ...
随机推荐
- 关于SSH不能连接及报错的问题总结
前言 此文不涉及到因网络.防火墙设备而导致的SSH不能访问.运维常见问题,这里不做过多的讲解,主要讲讲出了大家所知道的,还有其他什么原因会导致SSH无法访问呢?好了,那么,如果想知道的话,那就继续往下 ...
- 017 SpringMVC中CRUD实例
一:新建项目(下面的几乎属于公共的方法,不需要改动) 1.结构 2.添加lib 3.配置web.xml <?xml version="1.0" encoding=" ...
- sklearn.preprocessing.LabelEncoder的使用
在训练模型之前,我们通常都要对训练数据进行一定的处理.将类别编号就是一种常用的处理方法,比如把类别"男","女"编号为0和1.可以使用sklearn.prepr ...
- Linux使用tcpdump命令抓包并使用wireshark分析
Linux使用tcpdump命令抓包并使用wireshark分析 介绍 有时分析客户端和服务器网络交互的问题时,为了查找问题,需要分别在客户端和服务器上抓包,我们的客户端一般是windows上的,抓包 ...
- js算法初窥03(搜索及去重算法)
前面我们了解了一些常用的排序算法,那么这篇文章我们来看看搜索算法的一些简单实现,我们先来介绍一个我们在实际工作中一定用到过的搜索算法——顺序搜索. 1.顺序搜索 其实顺序搜索十分简单,我们还是以第一篇 ...
- Scala面向接口
trait Logger{ def log(message:String){ println("Logger:"+message) } } trait RichLogger ext ...
- mysql 用户/密码/权限操作
由于最近使用mysql遇到了修改用户密码的问题,所以一块学习了一下关于用户的相关操作: 1. 创建新账户 CREATE USER 'jeffrey'@'localhost'; 2. 账户设置密码 #当 ...
- BZOJ.5137.Standing Out from the Herd(广义后缀自动机)
题目链接 \(Description\) 对于每个串,求在\(n\)个串中只在该串中出现过的子串的数量. \(Solution\) 建广义SAM.对每个串插入时新建的np标记其属于哪个串. 然后在pa ...
- BZOJ.3262.陌上花开([模板]CDQ分治 三维偏序)
题目链接 BZOJ3262 洛谷P3810 /* 5904kb 872ms 对于相邻x,y,z相同的元素要进行去重,并记录次数算入贡献(它们之间产生的答案是一样的,但不去重会..) */ #inclu ...
- Linux 下 make 命令 及 make 笔记
Linux 下 make 命令是系统管理员和程序员用的最频繁的命令之一.管理员用它通过命令行来编译和安装很多开源的工具,程序员用它来管理他们大型复杂的项目编译问题.本文我们将用一些实例来讨论 make ...