Delphi - Http POST call

Programming/Delphi 2013.11.29 10:18 Posted by 파란크리스마스

Delphi - Http POST call

DelphiHttpPostCall.7z

procedure TForm1.Button1Click(Sender: TObject);
var
  sl : TStringList;
  ResponseStream: TMemoryStream;
  resultBytes: TBytes;
begin
  sl := TStringList.Create;
  ResponseStream := TStringStream.Create;
  try
    IdHTTP1.Request.ContentType := 'application/x-www-form-urlencoded';
    sl.Add('id=' + Edit2.Text);
    IdHTTP1.Post(Edit1.Text, sl, ResponseStream);
    ResponseStream.Position := 0;

    SetLength(resultBytes, ResponseStream.Size);
    ResponseStream.ReadBuffer(resultBytes[0], Length(resultBytes));

    Memo1.Lines.Text := TEncoding.UTF8.GetString(resultBytes);
  finally
    sl.Free;
    ResponseStream.Free;
  end;
end;
신고
TAG , ,


 

티스토리 툴바