Comment gérer TIdHTTPServer avec TIdMultiPartFormDataStream

Salut j'ai besoin d'aide sur comment faire pour récupéré les paramètres et les données à l'aide de IdHttpServer d'indy.

beaucoup de mon application utilise TIdMultiPartFormDataStream pour envoyer des données via le php. Je voudrais utiliser le TIdHTTPServer pour vérifier les paramètres pour une raison quelconque et de transmettre la demande à sa destination.

j'ai créé un petit exemple pour vous de voir.

uses
  IdContext, IdMultipartFormData;

// Server Side------------------------------------------------

IdHTTPServer1.Defaultport := 88;
IdHTTPServer1.active := True;

procedure TForm1.IdHTTPServer1CommandGet(AContext: TIdContext;
  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
begin
  // the request will be pass through its destination by POST/GET
  // and send the result back to the client apps.
  AResponseInfo.ContentText := ARequestInfo.Params.Text;
end;

// Client Side------------------------------------------------
// This will work using the standard Post or Get
procedure TForm1.btnPost1Click(Sender: TObject);
var
  sl: TStringList;
  res: String;
begin
  sl := TStringList.Create;
  try
    sl.Add('Param1=Data1');
    sl.Add('Param2=Data1');
    sl.Add('Param3=Data2');
    sl.Add('Param4=Data3');
    res := IdHTTP1.Post('http://localhost:88/some.php', sl);
    ShowMessage(res);
  finally
    sl.Free;
  end;
end;

//how can i get the parameters and value for this code in my IdHttpServer
procedure TForm1.btnPost2Click(Sender: TObject);
var
  mfd: TIdMultiPartFormDataStream;
  res: String;
begin
  mfd := TIdMultiPartFormDataStream.Create;
  try
    mfd.AddFormField('Param1', 'Data1');
    mfd.AddFormField('Param2', 'Data1');
    mfd.AddFormField('Param3', 'Data2');
    mfd.AddFormField('Param4', 'Data3');
    res := IdHTTP1.Post('http://localhost:88/some.php', mfd);
    ShowMessage(res);
  finally
    mfd.Free;
  end;
end;

et comment puis-je savoir si le Client applications de passer un TIdMultiPartFormDataStream type de paramètre?

OriginalL'auteur XBasic3000 | 2012-06-14