106 lines
2.6 KiB
C#
106 lines
2.6 KiB
C#
using Fiddler;
|
|
using System.Windows.Forms;
|
|
using Util;
|
|
using FiddlerDecryption.Controls;
|
|
|
|
namespace Request
|
|
{
|
|
/// <summary>
|
|
/// 益盟请求解码为格式化 JSON 字符串
|
|
/// </summary>
|
|
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();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 实现 <see cref="Fiddler.IBaseInspector2.bDirty"/> 字段
|
|
/// </summary>
|
|
public bool bDirty
|
|
{
|
|
get
|
|
{
|
|
return mBDirty;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 实现 <see cref="Fiddler.IBaseInspector2.body"/> 字段
|
|
/// </summary>
|
|
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);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 实现 <see cref="Fiddler.IBaseInspector2.bReadOnly"/> 字段
|
|
/// </summary>
|
|
public bool bReadOnly
|
|
{
|
|
get
|
|
{
|
|
return mBReadOnly;
|
|
}
|
|
|
|
set
|
|
{
|
|
mBReadOnly = value;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 实现 <see cref="Fiddler.IRequestInspector2.headers"/> 字段
|
|
/// </summary>
|
|
public HTTPRequestHeaders headers
|
|
{
|
|
get
|
|
{
|
|
return mRequestHeaders;
|
|
}
|
|
set
|
|
{
|
|
mRequestHeaders = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 实现 <see cref="Fiddler.Inspector2.AddToTab"/> 方法
|
|
/// </summary>
|
|
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;
|
|
}
|
|
}
|