Does gor support mark request sequence between current server and output-http server?
Hi, i have a requirement to mark request sequence. So we can compare current server request and response log to output-http server request and response log result?Then find which request have different response content.
Hello! Using --input-raw-track-response you can turn on response recording, after you can compare original response and replayed response in middleware (they will have same request id but different types, see middleware docs). I plan to include built-in comparison tool in further versions.
On Wednesday, 20 July 2016, niwei [email protected] wrote:
Hi, i have a requirement to mark request sequence. So we can compare current server request and response log to output-http server request and response log result?Then find which request have different response content.
â You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/buger/gor/issues/341, or mute the thread https://github.com/notifications/unsubscribe-auth/AAA2uTS6bFwd4YRhVpDplT7rNrwYsF5Eks5qXerFgaJpZM4JQl2q .
Sincerely yours Leonid Bugaev http://gortool.com - test your system with real data
But now i get original response and replayed response and find they request id is not same.
For example
original request and request:
1 2a020f4e9ea67b9b8b9a029a397f9fdc0bdd18a0 1469094502054038668 GET /v3/order/generate?activityGoodsInfos=&address_id=924550&app_version=IOS_2.4.9&area_id=672638&client=2&delivery_time=%E4%B8%80%E5%B0%8F%E6%97%B6%E4%B9%8B%E5%86%85&freight_type=1&goodsInfos=758143%3A2%2C840727%3A2&isUseDDP=false&is_use_balance=true&order_type=0&org_id=222&pay_id=1&postscript=&promo_code=&token=44573294b48246e98f33e64b532dfee8_150&userId=a4b55123100c8fcb733e7ded03465967b58017b3&user_id=a4b55123100c8fcb733e7ded03465967b58017b3&verifyCode=Toalzwd-gppx-CUEL2WFYDLFPKXIZ54URGAR6IM-xo&verify_code=Toalzwd-gppx-CUEL2WFYDLFPKXIZ54URGAR6IM-xo HTTP/1.1 Host: 192.168.40.204:8082 Connection: keep-alive Accept-Encoding: gzip, deflate User-Agent: 8Dol/2.4.9 (iPhone; iOS 9.3.2; Scale/2.00) Accept-Language: zh-Hans-CN;q=1, en-CN;q=0.9 Accept: /
đ”đđ 2 2a020f4e9ea67b9b8b9a029a397f9fdc0bdd18a0 2001941532 HTTP/1.1 200 OK Server: Apache-Coyote/1.1 X-Application-Context: application:test:8082 Content-Type: application/json;charset=UTF-8 Transfer-Encoding: chunked Date: Thu, 21 Jul 2016 09:48:23 GMT
62f {"result":"ok","msg":"æäœæć","code":200,"data":{"completion_time":null,"create_user_name":null,"promo_code":null,"area_id":672638,"type":0,"have_coupon":"false","building":716254,"partner_sn":false,"complaint_type":0,"alipay_scan_code_time":null,"accept_name":"ćȘç","pre_pay_status":null,"status_list":null,"order_amount":20.80,"picking_member":null,"id":5899394,"user_postscript":null,"area":680838,"cancel_time":null,"buyer_email":null,"create_user_id":0,"has_booked_goods":false,"sequence_num":0,"completion_flag":null,"dispatch_time":null,"create_time":"2016-07-21 17:48:22","rate_time":null,"self_balance_pay":20.80,"pre_order_status":null,"region_id":0,"sn_send_time":null,"evaluation_score":0,"pay_time":"2016-07-21 17:48:22","complaint_status":null,"send_time":null,"freight_mode":1,"user_id":10053523,"org_id":222,"admin_id":11,"ddp_balance_pay":0,"common_order":null,"night_user_id":null,"trade_no":null,"complaint_cancel_reason":null,"complaint_time":null,"status":1,"order_no":"M2016072109482200001","note":null,"wly":null,"postscript":"","freight":0,"picking_member_id":0,"promotion_id":0,"user_accept_time":null,"alipay_scan_code":false,"wly_id":null,"point":0,"pay_url":"","pay_status":1,"first_price":0,"client":2,"real_create_time":null,"send_status":false,"pay_type":2,"discount0616":0,"out_bound_time":null,"apply_pay_time":null,"address":"ćć","is_active":0,"mobile":"18625150155","sn_order":null,"promo_id":0,"balance_pay":20.80,"real_amount":20.80,"cancel_reason":null,"night_store_id":0,"full_discount":false,"payable_amount":20.80},"rescode":200} 0
The output http server capture the request and response are
1 2888494545d047bd667757dd43d2ab688a2c1488 1469094495697587634 GET /v3/order/generate?activityGoodsInfos=&address_id=924550&app_version=IOS_2.4.9&area_id=672638&client=2&delivery_time=%E4%B8%80%E5%B0%8F%E6%97%B6%E4%B9%8B%E5%86%85&freight_type=1&goodsInfos=758143%3A2%2C840727%3A2&isUseDDP=false&is_use_balance=true&order_type=0&org_id=222&pay_id=1&postscript=&promo_code=&token=44573294b48246e98f33e64b532dfee8_150&userId=a4b55123100c8fcb733e7ded03465967b58017b3&user_id=a4b55123100c8fcb733e7ded03465967b58017b3&verifyCode=Toalzwd-gppx-CUEL2WFYDLFPKXIZ54URGAR6IM-xo&verify_code=Toalzwd-gppx-CUEL2WFYDLFPKXIZ54URGAR6IM-xo HTTP/1.1 Host: 192.168.100.34:8082 Connection: keep-alive Accept-Encoding: gzip, deflate User-Agent: 8Dol/2.4.9 (iPhone; iOS 9.3.2; Scale/2.00) Accept-Language: zh-Hans-CN;q=1, en-CN;q=0.9 Accept: /
đ”đđ 2 2888494545d047bd667757dd43d2ab688a2c1488 5204721 HTTP/1.1 200 OK Server: Apache-Coyote/1.1 X-Application-Context: application:8082 Content-Type: text/html;charset=UTF-8 Content-Length: 112 Date: Thu, 21 Jul 2016 09:48:15 GMT
{"result":"fail","msg":"æšç莊ć·ćŻèœććšéźéą,èŻ·æšéæ°ç»ćœ","code":9401,"data":{},"rescode":9401}
original request header in gor are 1 2a020f4e9ea67b9b8b9a029a397f9fdc0bdd18a0 1469094502054038668
output http server request header 1 2888494545d047bd667757dd43d2ab688a2c1488 1469094495697587634
not same.
so i cant compare which is the same request.
Because i want to compare original server response with replayed server response log file.
Now, i add java middleware to implement it. Thank u. đ
`package gor;
import javax.xml.bind.DatatypeConverter; import java.io.*;
/**
-
Created by niwei on 16/7/22. */ public class AddHeader { private static final String SPLITTER_HEADER_BODY_SPLITTER = "\r\n\r\n";
private static final String SPLITTER_HEAD_FIRST_LINE = "\n";
private static final String SPLITTER_HEADER_ITEM = " ";
/**
- payload type, possible values: 1 - request, 2 - original response, 3 - replayed response */ private static final String PAYLOAD_TYPE_REQUEST = "1";
/**
-
convert hex to string *
-
@param hexStr
-
@return
-
@throws Exception */ public static String hexDecode(String hexStr) throws Exception { byte[] decodedHex = DatatypeConverter.parseHexBinary(hexStr); String decodedString = new String(decodedHex, "UTF-8");
return decodedString; }
/**
-
convert string to hex *
-
@param str
-
@return
-
@throws Exception */ public static String encodeHex(String str) throws Exception { byte[] strBytes = str.getBytes(); String encodeString = DatatypeConverter.printHexBinary(strBytes);
return encodeString; }
/**
-
add request parameter to gor content *
-
@param content original content
-
@return */ public static String addRequestParameter(String content) { String result = content;
/**
- get first line content */ String firstLine = content.substring(0, content.indexOf(SPLITTER_HEAD_FIRST_LINE)); if (firstLine == null) { return result; }
/**
-
parse first line */ String[] items = firstLine.split(SPLITTER_HEADER_ITEM); if (items.length != 3) { return result; } else { String payloadType = items[0]; String requestId = items[1];
if (PAYLOAD_TYPE_REQUEST.equals(payloadType)) { result = content.replaceFirst(SPLITTER_HEADER_BODY_SPLITTER, SPLITTER_HEADER_BODY_SPLITTER + "GorRequestId=" + requestId + "&"); } }
return result; }
public static void main(String[] args) throws Exception { if (args != null) { for (String arg : args) { System.out.println(arg); }
} BufferedReader stdin = new BufferedReader(new InputStreamReader( System.in)); String line; while ((line = stdin.readLine()) != null) { System.out.println(encodeHex(addRequestParameter(hexDecode(line)))); }
/* try (FileWriter fileWriter = new FileWriter(new File("/Users/niwei/work/copyflow/echo.txt")); BufferedWriter bufferedWriter = new BufferedWriter(fileWriter)) { while ((line = stdin.readLine()) != null) { System.out.println(line);
bufferedWriter.write(addRequestParameter(hexDecode(line)));
bufferedWriter.newLine();
bufferedWriter.flush();
}
}*/
}
} `