Cara Membuat Response Bug Di Delphi 7

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 8

1.

Tambahin Boolean Dulu Di Private Declaration di Form Anda:

private
enabledDuaRatusOK:boolean; // INI ADALAH BOOLEANNYA
{ Private declarations }

2. Tambahin Script Dibawah ini di TCP On Connect:

if enabledDuaRatusOK = True then begin


enabledDuaRatusOK := False;
end;

3. Tambahin komponen StatusBar / Label lalu beri script dibawah ini di TCP On
OutboundData
(Ganti bsSkinStatusPanel3.Caption dengan nama komponen di Form Anda):

if Pos (' 500 Internal Server Error', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'500 Internal Server
Error','200 OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 500 (Internal Server Error)';
end;
if Pos (' 501 Not Implemented', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'501 Not Implemented','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 501 (Not Implemented)';
end;
if Pos (' 502 Bad Gateway', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'502 Bad Gateway','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 502 (Bad Gateway)';
end;
if Pos (' 503 Service Unavailable', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'503 Service Unavailable','200
OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 503 (Service Unavailable)';
end;
if Pos (' 504 Gateway Timeout', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'504 Gateway Timeout','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 504 (Gateway Timeout)';
end;
if Pos (' 505 HTTP Version Not Supported', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'505 HTTP Version Not
Supported','200 OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 505 (HTTP Version Not
Supported)';
end;
if Pos (' 506 Variant Also Negotiates', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'506 Variant Also
Negotiates','200 OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 506 (Variant Also
Negotiates)';
end;
if Pos (' 507 Insufficient Storage', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'507 Insufficient Storage','200
OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 507 (Insufficient Storage)';
end;
if Pos (' 508 Loop Detected', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'508 Loop Detected','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 508 (Loop Detected)';
end;
if Pos (' 510 Not Extended', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'510 Not Extended','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 510 (Not Extended)';
end;
if Pos (' 511 Network Authentication Required', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'511 Network Authentication
Required','200 OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 511 (Network Authentication
Required)';
end;

//*** RESPONSE 400 ***//


if Pos (' 408 Request Time-out', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'408 Request Time-out','200
OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 408 (Request Time-out)';
end;
if Pos (' 404 Not Found', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'404 Not Found','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 404 (Not Found)';
end;
if Pos (' 403 Forbidden', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'403 Forbidden','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 403 (Forbidden)';
end;
if Pos (' 400 Bad Request', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'400 Bad Request','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 400 (Bad Request)';
end;
if Pos (' 417 Expectation Failed', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'417 Expectation Failed','200
OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 417 (Expectation Failed)';
end;
if Pos (' 401 Unauthorized', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'401 Unauthorized','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 401 (Unauthorized)';
end;
if Pos (' 402 Payment Required', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'402 Payment Required','200
OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 402 (Payment Required)';
end;
if Pos (' 405 Method Not Allowed', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'405 Method Not Allowed','200
OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 405 (Method Not Allowed)';
end;
if Pos (' 406 Not Acceptable', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'406 Not Acceptable','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 406 (Not Acceptable)';
end;
if Pos (' 407 Proxy Authentication Required', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'407 Proxy Authentication
Required','200 OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 407 (Proxy Authentication
Required)';
end;
if Pos (' 409 Conflict', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'409 Conflict','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 409 (Conflict)';
end;
if Pos (' 410 Gone', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'410 Gone','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 410 (Gone)';
end;
if Pos (' 411 Length Required', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'411 Length Required','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 411 (Length Required)';
end;
if Pos (' 412 Precondition Failed', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'412 Precondition Failed','200
OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 412 (Precondition Failed)';
end;
if Pos (' 413 Payload Too Large', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'413 Payload Too Large','200
OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 413 (Payload Too Large)';
end;
if Pos (' 414 URI Too Long', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'414 URI Too Long','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 414 (URI Too Long)';
end;
if Pos (' 415 Unsupported Media Type', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'415 Unsupported Media
Type','200 OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 415 (Unsupported Media
Type)';
end;
if Pos (' 416 Range Not Satisfiable', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'416 Range Not
Satisfiable','200 OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 416 (Range Not Satisfiable)';
end;
if Pos (' 421 Misdirected Request', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'421 Misdirected Request','200
OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 421 (Misdirected Request)';
end;
if Pos (' 422 Unprocessable Entity', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'422 Unprocessable Entity','200
OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 422 (Unprocessable Entity)';
end;
if Pos (' 423 Locked', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'423 Locked','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 423 (Locked)';
end;
if Pos (' 424 Failed Dependency', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'424 Failed Dependency','200
OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 424 (Failed Dependency)';
end;
if Pos (' 426 Upgrade Required', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'426 Upgrade Required','200
OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 426 (Upgrade Required)';
end;
if Pos (' 428 Precondition Required', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'428 Precondition
Required','200 OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 428 (Precondition Required)';
end;
if Pos (' 429 Too Many Requests', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'429 Too Many Requests','200
OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 429 (Too Many Requests)';
end;
if Pos (' 431 Request Header Fields Too Large', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'431 Request Header Fields Too
Large','200 OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 431 (Request Header Fields
Too Large)';
end;
if Pos (' 451 Unavailable For Legal Reasons', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'451 Unavailable For Legal
Reasons','200 OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 451 (Unavailable For Legal
Reasons)';
end;

//*** RESPONSE 300 ***//


if Pos (' 300 Multiple Choices', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(AThread.NetData,'300 Multiple Choices','200
OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 300 (Multiple Choices)';
end;
if Pos (' 307 Temporary Redirect', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(AThread.NetData,'307 Temporary Redirect','200
OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 307 (Temporary Redirect)';
end;
if Pos (' 302 Found', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'302 Found','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 302 (Found)';
end;
if Pos (' 302 Moved Temporarily', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'302 Moved Temporarily','200
OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 302 (Moved Temporarily)';
end;
if Pos (' 301 Moved Permanently', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'301 Moved Permanently','200
OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 301 (Moved Permanently)';
end;
if Pos (' 303 See Other', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(AThread.NetData,'303 See Other','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 303 (See Other)';
end;
if Pos (' 304 Not Modified', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(AThread.NetData,'304 Not Modified','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 304 (Not Modified)';
end;
if Pos (' 305 Use Proxy', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(AThread.NetData,'305 Use Proxy','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 305 (Use Proxy)';
end;
if Pos (' 306 Switch Proxy', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(AThread.NetData,'306 Switch Proxy','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 306 (Network Authentication
Required)';
end;
if Pos (' 307 Temporary Redirect', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(AThread.NetData,'307 Temporary Redirect','200
OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 307 (Temporary Redirect)';
end;
if Pos (' 308 Permanent Redirect', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(AThread.NetData,'308 Permanent Redirect','200
OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 308 (Permanent Redirect)';
end;

//*** RESPONSE 200 ***//


if Pos (' 201 Created', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'201 Created','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 201 (Created)';
end;
if Pos (' 203 Non-Authoritative Information', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'203 Non-Authoritative
Information','200 OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 203 (Non-Authoritative
Information)';
end;
if Pos (' 204 No Content', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'204 No Content','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 204 (No Content)';
end;
if Pos (' 205 Reset Content', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'205 Reset Content','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 205 (Reset Content)';
end;
if Pos (' 206 Partial Content', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'206 Partial Content','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 206 (Partial Content)';
end;
if Pos (' 207 Multi-Status', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'207 Multi-Status','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 207 (Multi-Status)';
end;
if Pos (' 208 Already Reported', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'208 Already Reported','200
OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 208 (Already Reported)';
end;
if Pos (' 226 IM Used', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(athread.NetData,'226 IM Used','200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: 226 (226 IM Used)';
end;

//****************************************

if Pos (' HTTP/1.1', AThread.NetData) <>0 then begin


enabledDuaRatusOK := True;
AThread.NetData := StringReplace(AThread.NetData,' HTTP/1.1',' HTTP/1.0',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: HTTP/1.1';
end;
if Pos (' EHTTP/1.1 200 OK', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(AThread.NetData,' EHTTP/1.1 200 OK','
EHTTP/1.0 200 OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: EHTTP/1.1 200 OK';
end;
if Pos (' HTTPS/1.1', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(AThread.NetData,' HTTPS/1.1',' HTTPS/1.0',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: HTTPS/1.1';
end;
if Pos (' HTTPS/1.1 200 OK', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(AThread.NetData,' HTTPS/1.1 200 OK','
HTTPS/1.0 200 OK',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: HTTPS/1.1 200 OK';
end;
if Pos (' %2f', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(AThread.NetData,' %2f',' /',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: %2f';
end;
if Pos (' %20', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(AThread.NetData,' %20',' _',[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: %20';
end;
if Pos (' Set-Cookie', AThread.NetData) <>0 then begin
enabledDuaRatusOK := True;
AThread.NetData := StringReplace(AThread.NetData,' Set-Cookie',' 200 OK',
[rfReplaceAll]);
bsSkinStatusPanel3.Caption :=' Response Received: Set-Cookie';
end;

if Pos (' 200 Connection established', AThread.NetData) <>0 then begin


enabledDuaRatusOK := True;
bsSkinStatusPanel3.Caption :=' Response Received: 200 (Connection
established)';
end;

if enabledDuaRatusOK = False then begin


bsSkinStatusPanel3.Caption :=' Response Received: 200 (OK)';
AThread.NetData := StringReplace(athread.NetData,'200 OK','200 OK',
[rfReplaceAll]);
enabledDuaRatusOK := True;
end;

You might also like