TA的每日心情 | 开心 2015-3-20 10:58 |
---|
签到天数: 1 天 连续签到: 1 天 [LV.1]测试小兵
|
- //------组成请求的body
- char* body = (char*) malloc (10485760 * sizeof(char));
- char *fenge="-----------------------------28490279842474\r\n";
- long length=0;
- char len[1024];
- char filename[1024];
- char *fname = (char*) malloc (4194404 * sizeof(char));
- long bodylength=0;
- char bodylen[1024];
-
- //生成随机的文件名字
- int s;
- s=rand()%20000+1;
- rand( );
- lr_save_int(s, "filename");
- strcpy( fname,
- lr_eval_string("{filename}-") );
- //生成时间戳
- lr_save_datetime("%Y%m%d-%H%M%S", DATE_NOW, "nowtime");
- strcat( fname,
- lr_eval_string("{nowtime}") );
- // lr_save_string(lr_eval_string("{nowtime}"),"filename");
-
- strcpy( body,fenge );
- strcat( body,"Content-Disposition: form-data; name=\"parentId\"\r\n\r\n" );
- strcat( body,lr_eval_string("{rootFolderId}") );
- strcat( body,"\r\n" );
- strcat( body,fenge );
- strcat( body,"Content-Disposition: form-data; name=\"ondup\"\r\n\r\noverwrite\r\n" );
- strcat( body,fenge );
- strcat( body,"Content-Disposition: form-data; name=\"id\"\r\n\r\nWU_FILE_0\r\n" );
- strcat( body,fenge );
- // strcat(body,"Content-Disposition: form-data; name=\"name\"\r\n\r\n{filename}\r\n");
- // strcat(body,fenge);
- strcat( body,"Content-Disposition: form-data; name=\"type\"\r\n\r\napplication/octet-stream\r\n" );
- strcat( body,fenge );
- strcat( body,"Content-Disposition: form-data; name=\"size\"\r\n\r\n1024\r\n" );
- strcat( body,fenge );
- // strcat(body,"Content-Disposition: form-data; name=\"lastModifiedDate\"\r\n\r\nWed Apr 05 2017 16:43:55 GMT+0800\r\n");
- // strcat(body,fenge);
- strcat( body,"Content-Disposition: form-data; name=\"file\"; filename=\"" );
- // strcat(body,lr_eval_string("{fname}"));
- strcat( body,fname );
- strcat( body,"\"\r\nContent-Type: application/octet-stream\r\n\r\n" );
- strcat( body,lr_eval_string("{contentTemp}") );
- strcat( body,"\r\n\r\n" );
- strcat( body,"-----------------------------28490279842474--" );
- lr_save_string( body,"requestbody" );
- length=strlen(body);
- // length=strlen( lr_eval_string("{requestbody}") );
- lr_output_message("length is %d",length);
- itoa( length,len,10 );
- lr_save_string( len,"bodylength" );
- free( body );
- free(fname);
- fname=NULL;
- body=NULL;
- //------------------
- //模拟用户真实操作,每次操作完成后,休息3秒钟
- lr_think_time(3);
- //设置检查点,检查返回的信息是否含有allParentid字符串。
- web_reg_find("Fail=NotFound",
- "Search=Body",
- "SaveCount=1",
- "Text=******", //屏蔽信息
- LAST);
- web_reg_save_param("****", //屏蔽信息
- "Search=Body",
- "LB=id\":\"",
- "RB=\",\"name",
- LAST);
- //事务开始
- lr_start_transaction("upload");
- web_add_header("Content-Length",
- "{bodylength}");
- web_add_header("Content-Type",
- "multipart/form-data; boundary=---------------------------28490279842474");
- // lr_output_message("content-length is %s", lr_eval_string("{bodylength}"));
- // lr_output_message("requstbody is %s", lr_eval_string("{requestbody}"));
- // web_add_header("HOST","10.0.100.18");
- // 实现上传。
- web_custom_request("content",
- "URL={url}", //url是固定的,这里屏蔽显示
- "Method=POST",
- "Resource=0",
- "Referer=",
- "Mode=HTTP",
- "Body={requestbody}",
- LAST);
- //事务结束
- lr_end_transaction("upload", LR_AUTO);
复制代码 在web_custom_request("content", 这行显示错误:
memory violation : Exception ACCESS\_VIOL
之前是在length=strlen( lr_eval_string("{requestbody}") ); 这行显示错误,后来注释掉,直接用length=strlen(body),这行的错误就没有了。
现在在请求的时候又发生这样的错误。
在回访的时候迭代多少次都没有错误。但是只要一并发运行超过40就开始返回这样的错误。
找了很多文档都没有找到解决办法。。。。。。。。。。。。。。。。。。。。
请求大神支持一下。
|
|