This repository has been archived by the owner on Nov 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
EvilWorks.Design.HTTPHeadersEditor.pas
124 lines (110 loc) · 2.3 KB
/
EvilWorks.Design.HTTPHeadersEditor.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
unit EvilWorks.Design.HTTPHeadersEditor;
{$R *.dfm}
interface
uses
Winapi.Windows,
Winapi.Messages,
System.SysUtils,
System.Variants,
System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
Vcl.StdCtrls,
Vcl.ComCtrls,
Vcl.ExtCtrls,
DesignEditors,
DesignIntf,
EvilWorks.Web.HTTP;
type
{ }
THTTPHeadersProperty = class(TClassProperty)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
end;
{ }
THTTPHeadersPropertyEditorForm = class(TForm)
pnlFooter: TPanel;
btnOK: TButton;
btnCancel: TButton;
bvlFooter: TBevel;
lvHeaders: TListView;
BtnClear: TButton;
BtnDelete: TButton;
BtnAdd: TButton;
EdtValue: TEdit;
EdtKey: TEdit;
lblValue: TLabel;
lblKey: TLabel;
lblHeaders: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
FHeaders: THTTPMessage;
public
procedure ReloadHeaders;
property HTTPHeaders: THTTPMessage read FHeaders write FHeaders;
end;
implementation
{ ==================== }
{ THTTPHeadersProperty }
{ ==================== }
{ }
procedure THTTPHeadersProperty.Edit;
var
frm: THTTPHeadersPropertyEditorForm;
begin
Application.CreateForm(THTTPHeadersPropertyEditorForm, frm);
try
frm.Caption := Self.GetName;
frm.HTTPHeaders.Assign(THTTPMessage(GetOrdValue));
frm.ReloadHeaders;
if (frm.ShowModal = mrOk) then
begin
THTTPMessage(GetOrdValue).Assign(frm.HTTPHeaders);
Modified;
end;
finally
frm.Free;
end;
end;
{ }
function THTTPHeadersProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paMultiSelect, paAutoUpdate];
end;
{ ============================== }
{ THTTPHeadersPropertyEditorForm }
{ ============================== }
{ }
procedure THTTPHeadersPropertyEditorForm.FormCreate(Sender: TObject);
begin
FHeaders := THTTPMessage.Create;
end;
{ }
procedure THTTPHeadersPropertyEditorForm.FormDestroy(Sender: TObject);
begin
FHeaders.Free;
end;
{ }
procedure THTTPHeadersPropertyEditorForm.ReloadHeaders;
var
i : integer;
li: TListItem;
begin
lvHeaders.Items.BeginUpdate;
try
lvHeaders.Clear;
for i := 0 to HTTPHeaders.Count - 1 do
begin
li := lvHeaders.Items.Add;
li.Caption := HTTPHeaders[i].Key;
li.SubItems.Add(HTTPHeaders[i].Val);
end;
finally
lvHeaders.Items.EndUpdate;
end;
end;
end.