function URLEncode(const S: string; const InQueryString: Boolean = False): string;
var
Idx: Integer; // loops thru characters in string
begin
Result := '';
for Idx := 1 to Length(S) do
begin
case S[Idx] of
'A'..'Z', 'a'..'z', '0'..'9', '-', '_', '.', '=':
Result := Result + S[Idx];
' ':
if InQueryString then
Result := Result + '+'
else
Result := Result + '%20';
else
Result := Result + '%' + SysUtils.IntToHex(Ord(S[Idx]), 2);
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
Var
aStream: TMemoryStream;
Params: TStringStream;
begin
aStream := TMemoryStream.create;
Params := TStringStream.create('');
try
with IdHTTP1 do
begin
Params.WriteString(URLEncode('madedata=' + Edit1.Text));
Request.ContentType := 'application/x-www-form-urlencoded';
try
Post('
http://123.140.215.235/test/Result.jsp', Params, aStream);
except
on E: Exception do
showmessage('Error encountered during POST: ' + E.Message);
end;
end;
aStream.WriteBuffer(#0' ', 1);
aStream.Position := 0;
Memo1.Lines.LoadFromStream(aStream);
except
end;
end;
이렇게 하면 동작합니다.
다만, 결과물을 리턴 받을때 사이에 있는 것을 파싱해야 하는데
파싱을 위한 어떤 정보도 없으므로 잘라내기가 곤란할 것으로 보이네요.
서버에서 작업한 내용을 xml 방식으로 돌려주면 클라이언트에서 처리하기가
아주 편할 듯 합니다만...