I have a simple procedure, just sending a file stream to web server. But when there are any content in the stream, the server does not work --- respond 500 error.
// this is client-side procedure
procedure TForm1.Button2Click(Sender: TObject);
var
httpclient: TFPHTTPClient;
astr, ss: TStringSTream;
begin
// memo1.Clear;
httpClient:= TfpHttpClient.Create(nil);
astr:= TStringStream.Create(edit1.text); // works if edit1.text = '', not with any text
ss:= TStringStream.Create;
httpclient.StreamFormPost('http://alphaq.codns.com/aq/aq03e',
'fieldname', 'filename', astr, ss);
showmessage(ss.DataString);
astr.free;
ss.free;
end;
//========= server side
procedure TwmAQe.DataModuleRequest(Sender: TObject; ARequest: TRequest;
AResponse: TResponse; var Handled: Boolean);
var
n: Integer;
f: TUploadedFile;
i: Integer;
begin
n:= ARequest.Files.Count;
if n >= 1
then AResponse.Content:= 'file found'
else AResponse.Content:= 'no file';
handled:= True;
end;
I wrote this in another thread, but at that time I thought the problem lies in the treatment of stream. Now I think this may be server-side problem.
When there are no text, it will showmessage 'no file', but when there are any texts, then this shows 500 error.
Interestingly, I have tested these procedures a few months ago. Then, everything worked fine. I'd like to know whether this is replicable in other environments. Both client and server are running on windows 10.