procedure
TForm1
.
btn1Click(Sender: TObject);
var
stream : TStringStream;
http1,httpsend : THTTPSend;
Res :
boolean
;
n :
integer
;
KSlink,TOKEN,NewURL:
string
;
begin
httpsend:=THTTPSend
.
Create;
http1:=THTTPSend
.
Create;
mmo3
.
Lines
.
LoadFromStream(http1
.
Document);
TOKEN:=Copy(mmo3
.
Text, Pos(
'org.apache.struts.taglib.html.TOKEN'
, mmo3
.
Text)+
44
,
32
);
edt1
.
Text:=TOKEN;
stream:=TStringStream
.
Create(
''
);
stream
.
WriteString(
'org.apache.struts.taglib.html.TOKEN='
+TOKEN+
'&isSubmitted=true&USERNAME=&USER_NAME=&ORIG_URL=&isInetUser=null&buser=&bpath=&user=%2B38'
+edt2
.
Text+
'&password=435465&Submit=%C2%F5%B3%E4+%E2+%F1%E8%F1%F2%E5%EC%F3&value%28jumpTo%29=&value%28jumpToUrl%29='
);
httpsend
.
MimeType:=
'application/x-www-form-urlencoded'
;
httpsend
.
Document
.
LoadFromStream(stream);
if
Res
then
case
httpsend
.
ResultCode
of
301
,
302
,
307
:
begin
n := FoundLocationStrNum(httpsend
.
Headers);
if
(n >=
0
)
and
(n <= httpsend
.
Headers
.
count)
then
begin
NewURL := StringReplace(httpsend
.
Headers
.
Strings[n],
'Location: '
,
''
,[]);
httpsend
.
Headers
.
Clear;
httpsend
.
HTTPMethod(
'GET'
,NewURL);
edt3
.
Text:=NewURL;
mmo2
.
Lines
.
Text:=GetHTTPStr(httpsend);
end
;
end
;
end
;
end
;