[fpc-pascal] Troubles with CGI and POST content
Sven Barth
svenmauren at vr-web.de
Sun Nov 15 12:45:55 CET 2009
Hello together!
I'm working on a little personal website and encountered a very strange
problem with the content that is sent by a form:
I run the attached CGI test application on my webspace which is a x86_64
Linux. When I enter text which contains a certain amount of
characters/bytes into the textarea and submit that form, a part of the
content seems to be truncated (all zeros) - this includes the
name-value-pair of the submit button (which is sent after the textarea)
so that the submit is not detected. It doesn't matter if my application
is compiled for i386 or x86_64.
The problem doesn't appear when I run the app on my local servers (i386
Linux and Windows).
This "magical amount" is reached earlier when I use multi byte
characters (e. g. umlauts).
What can be the problem? Can it be a configuration problem of Apache?
(all three computers run Apache) Or is it a problem because the webspace
has a different "library environment" than my local computers? (but
the executable has no dependencies?!)
Regards,
Sven
-------------- next part --------------
program cgitest;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes
{ you can add units after this }, custcgi, HTTPDefs, sysutils;
type
TMyCGITest = class(TCustomCGIApplication)
procedure handleRequest(ARequest: TRequest; AResponse: TResponse);
override;
end;
{ TMyCGITest }
procedure TMyCGITest.handleRequest(ARequest: TRequest; AResponse: TResponse);
var
msg: String;
begin
if ARequest.ContentFields.Values['button'] <> '' then
msg := 'This was a POST'
else
msg := 'This was not a POST';
AResponse.ContentType := 'text/html; charset=utf-8';
AResponse.Content :=
'<html>' +
'<head><title>CGI Test</title><meta http-equiv="content-type" content="text/html; charset=UTF-8" /></head>' +
'<body><p>' + msg + '</p><form method="POST" action="./cgitest" accept-charset="UTF-8"><p><textarea rows="15" cols="80" name="text">' + ARequest.ContentFields.Values['text'] + '</textarea></p><p><input type="submit" name="button" value="Send" /></form></body>' +
'</html>';
end;
{$IFDEF WINDOWS}{.$R cgitest.rc}{$ENDIF}
var
app: TMyCGITest;
begin
app := TMyCGITest.Create(Nil);
try
app.Initialize;
app.Run;
finally
app.Free;
end;
end.
More information about the fpc-pascal
mailing list