TidHttp.Post, unable to retrieve the posted fields on webserver

Giganews Newsgroups
Subject: TidHttp.Post, unable to retrieve the posted fields on webserver
Posted by:  Robert Ehrenhard (r.ehrenha…@chello.nl)
Date: Sun, 20 Nov 2005

Hello,

Help!!!

I am sending form field(s) with the TIdHTTP.Post command (Indy version
10.0.52).
The ASP page however does not receive/recognize the posted formfield(s)?

See below for the source code used.

Thank you for any help on this.

Regards, Robert Ehrenhard

Below is the Delphi 7 source code:
###########################################################
procedure TForm1.Button1Click(Sender: TObject);
var
  PostStream : TIdMultiPartFormDataStream;
  ResponseStream : TStringStream;
begin
  PostStream := TIdMultiPartFormDataStream.Create;
  ResponseStream := TStringStream.Create('');
  try
    PostStream.AddFormField('formfield1', 'blablabla');
    with HTTP do begin
      try
        HTTP.Post('http://www.somedomain.com/temp/xmlfile.asp',PostStream,ResponseStream);
      except
        on E: Exception do
          showmessage('Error encountered during POST: ' + E.Message);
      end;
    end;
  finally
    showmessage(ResponseStream.DataString);
    PostStream.Free;
    ResponseStream.Free;
  end;
end;

Below is the sASP page source code:
###########################################################
<% @ Language=VBScript %>
<%
Dim filesys, txtstream , xmlstring
xmlstring = request.form("formfield1")
set filesys = CreateObject ("Scripting.FileSystemObject")
set txtstream =
filesys.CreateTextFile(Server.MapPath("xmlresults.txt"),true)
txtstream.write Request.Form("formfield1")
txtstream.write Request.Form.Count
txtstream.write Request.ServerVariables("ALL_RAW")
txtstream.Close
%>

Below is the ASP page result written to "xmlresults.txt" from the ASP
script.
The first line should be the field name and value, but they are missing:
###########################################################
Connection: keep-alive
Content-Length: 121
Content-Type: multipart/form-data; boundary=--------112005221655640
Accept: text/html, */*
Accept-Encoding: identity
Host: www.somedomain.com
User-Agent: Mozilla/3.0 (compatible; Indy Library)

Replies