[fpc-pascal] Premature end of headers using fcl-web and POST
Sven Barth
pascaldragon at googlemail.com
Mon Oct 31 19:14:01 CET 2011
On 31.10.2011 16:56, Felipe Monteiro de Carvalho wrote:
> Ok, I figured part of it out. I can get past the exception if I use 2.5.1
>
> And the action was necessary, which is really strange because it
> worked nicely without it when using GET
>
> But now my problem is that I cannot get my POST data. I tryed this so far:
>
> lData := ARequest.ContentFields.Text;
>
> but it is empty.
>
If you'd look at the current version of TRequest.InitPostVars, you'd
know why it is empty ;)
=== source begin ===
procedure TRequest.InitPostVars;
Var
M : TCapacityStream;
Cl : Integer;
CT : String;
begin
{$ifdef CGIDEBUG}
SendMethodEnter('InitPostVars');
{$endif}
CL:=ContentLength;
if CL<>0 then
begin
M:=TCapacityStream.Create;
Try
if CL<>0 then
begin
M.Capacity:=Cl;
M.WriteBuffer(Content[1], Cl);
end;
M.Position:=0;
CT:=ContentType;
if Pos('MULTIPART/FORM-DATA',Uppercase(CT))<>0 then
ProcessMultiPart(M,CT, ContentFields)
else if Pos('APPLICATION/X-WWW-FORM-URLENCODED',Uppercase(CT))<>0
then
ProcessUrlEncoded(M, ContentFields)
finally
M.Free;
end;
end;
{$ifdef CGIDEBUG}
SendMethodExit('InitPostVars');
{$endif}
end;
=== source end ===
So it seems that you MUST set the contenttype either to
MULTIPART/FORM-DATA or APPLICATION/X-WWW-FORM-URLENCODED.
Maybe TRequest should be extended by something like an "unknown content
type handler"...
Regards,
Sven
More information about the fpc-pascal
mailing list