using Fiddler;
using System.Windows.Forms;
using Util;
using FiddlerDecryption.Controls;
namespace Request
{
///
/// 益盟请求解码为格式化 JSON 字符串
///
public sealed class RequestDecode : Inspector2, IRequestInspector2
{
private bool mBDirty;
private bool mBReadOnly;
private byte[] mBody;
private HTTPRequestHeaders mRequestHeaders;
private RequestDecodeControl requestDecodeControl;
public RequestDecode()
{
requestDecodeControl = new RequestDecodeControl();
}
///
/// 实现 字段
///
public bool bDirty
{
get
{
return mBDirty;
}
}
///
/// 实现 字段
///
public byte[] body
{
get
{
return mBody;
}
set
{
mBody = value;
requestDecodeControl.SetData(
DecodeUtil.DoDecryptionNew(headers, mBody).Result,
DecodeUtil.NeedToDecrypt(headers) && headers.Exists("Authorization") ?
headers["Authorization"] : string.Empty);
}
}
///
/// 实现 字段
///
public bool bReadOnly
{
get
{
return mBReadOnly;
}
set
{
mBReadOnly = value;
}
}
///
/// 实现 字段
///
public HTTPRequestHeaders headers
{
get
{
return mRequestHeaders;
}
set
{
mRequestHeaders = value;
}
}
///
/// 实现 方法
///
public override void AddToTab(TabPage o)
{
requestDecodeControl.AddToTab(o);
o.Text = "EProtobuf";
}
public void Clear()
{
mBody = null;
requestDecodeControl.Clear();
}
// 在 Tab 上的摆放位置
public override int GetOrder() => 200;
}
}