在上图中,Request Body
POST
FiddlerCore dll
请求private void FiddlerApplication_AfterSessionComplete(Session sess)
{
string requestBody = "";
if (sess.oRequest != null)
{
if (sess.oRequest.headers != null)
{
requestBody = sess.GetRequestBodyAsString();
}
}
}
。
以下是我捕捉它的方式:
string
但是,我只需要在它的参数(图片中的最后一行)的情况下捕获它,而在另一种情况下我不需要捕获它。
我可以使用self.navigationItem.title = ""
过滤它,这是我到目前为止所做的。但是,这样做的正确方法是什么?
注意:图片上的每一行都是不同的请求,总共5个。
答案 0 :(得分:1)
如果没有内容类型,则忽略它。弄清楚你想要的那些并拿走那些。
private void FiddlerApplication_AfterSessionComplete(Session sess) {
if (sess == null || sess.oRequest == null || sess.oRequest.headers == null)
return;
// Ignore HTTPS connect requests or other non-POST requests
if (sess.RequestMethod == "CONNECT" || sess.RequestMethod != "POST")
return;
var reqHeaders = sess.oRequest.headers.ToString(); //request headers
// Get the content type of the request
var contentType = sess.oRequest["Content-Type"];
// Lets assume you have a List<string> of approved content types.
// Ignore requests that do not have a content type
// or are not in the approved list of types.
if(contentType != null && !approvedContent.Any(c => contentType.Containes(c))
return;
var reqBody = sess.GetRequestBodyAsString();//get the Body of the request
//...other code.
}