Strange problem: Java --> Delphi cgi

My apologies in advance for the long post but this problem taks some
explaining.  Please read on.

I have a strange problem that I thought I had solved months ago but that
just reappeared when I moved some of my Delphi code from isapi to
stand-alone cgi.  I have a Java applet that allows the university's
business school alumni to search an online directory (data stored in
Sybase 11).  FYI, due to some problems some users experienced at some
locations with the Java version, there is also an isapi/cgi version
implemented entirely in Delphi.  Both versions are currently in
production.

One part of the Java code allows the user to email demographic
corrections to the General Alumni Association.  The user enters data on
a Java frame in text field and multi-line text area controls.  The Java
code then simulates an html form doing a POST to fire off a standalone
cgi written with Delphi 3.02 c/s.  The cgi program formats the data then
uses ArgoSoft's TSMTP component to send the email.

Everything is fine with the single-line data entered in Java's
equivalent of edit boxes.  However, the multi-line text fields all get
truncated to just their first line -- not a very good situation when two
of those fields contain multi-line address correction information.  The
multi-line text fields will usually contain line breaks between lines of
data.

I encountered this problem months ago when the smtp code was in an isapi
dll (we just moved it to a standalone cgi because of problems we were
encountering with smtp in isapi).  I solved it then by writing my own
parsing routine, passing it Request.Content and searching for the
Name=Value pairs for the multi-line fields (ContentFields.Values always
contained the truncated data), then returning the Value string.  This
scenario worked well in isapi.

However, now that I've ported the smtp code to cgi, the problem has
reappeared.  The form data string built by the Java code looks fine on
the Java end.  ContentFields in the Delphi code are all loaded except
that the multi-line fields are truncated to just the first line. My own
parsing logic also now returns just the first line of the multi-line
fields when passed Request.Content.  If I insert Request.Content in the
email message that is sent, only the Name=Value pair for the first field
sent by the Java code shows up (this first field just happens to be one
of the multi-line fields, and only the first line shows up).  The first
field in the data string built by Java is named 'Comments'.  If the user
enters:

Line 1
Line 2
Line 3

then sends the message, the following shows up in Request.Content when I
display it:

Comments=Line 1

Request.Content should contain not only the remaining 'Comments' lines
but a number of other fields as well.  Request.ContentLength appears to
contain the correct length (usually something over 400 depending on
exactly what is entered in the Java applet).

The isapi/cgi version of this application, where the data to be sent via
smtp is entered on a conventional html form returned to the browser by
the isapi portions of the application, works just fine.  The multi-line
fields are all passed to and processed by the Delphi cgi correctly.
What is even stranger is that if I hit the enter key twice between each
line of the multi-line fields,  Delphi seems to parse them out
approximately correctly (there still seems to be some field overlap but
at least all the data is there)!

This one has really got me puzzled and any help/suggestions will be
greatly appreciated.

Thanks,
================================================
Ray Porter
Applications Analyst Programmer
Administrative Information Services, UNC-CH
Phone: 966-5878
email: l...@email.adp.unc.edu
         dra...@email.unc.edu
Home Page: http://www.adp.unc.edu/~allrp/

"Meddle not in the affairs of dragons,
for you are crunchy and taste good with ketchup."