Recent

Author Topic: [SOLVED] Can anybody verify this?  (Read 796 times)

egsuh

  • Hero Member
  • *****
  • Posts: 1296
[SOLVED] Can anybody verify this?
« on: February 21, 2021, 06:38:27 am »
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.

Code: Pascal  [Select][+][-]
  1. // this is client-side procedure
  2.  
  3. procedure TForm1.Button2Click(Sender: TObject);
  4. var
  5.    httpclient: TFPHTTPClient;
  6.    astr, ss: TStringSTream;
  7. begin
  8.    // memo1.Clear;
  9.    httpClient:= TfpHttpClient.Create(nil);
  10.    astr:= TStringStream.Create(edit1.text);  // works if edit1.text = '', not with any text
  11.    ss:= TStringStream.Create;
  12.  
  13.    httpclient.StreamFormPost('http://alphaq.codns.com/aq/aq03e',
  14.           'fieldname', 'filename', astr, ss);
  15.    showmessage(ss.DataString);
  16.    astr.free;
  17.    ss.free;
  18. end;
  19.  
  20. //=========  server side
  21.  
  22. procedure TwmAQe.DataModuleRequest(Sender: TObject; ARequest: TRequest;
  23.    AResponse: TResponse; var Handled: Boolean);
  24. var
  25.   n: Integer;
  26.   f: TUploadedFile;
  27.   i: Integer;
  28. begin
  29.   n:= ARequest.Files.Count;
  30.   if n >= 1
  31.      then AResponse.Content:= 'file found'
  32.      else AResponse.Content:= 'no file';
  33.   handled:= True;
  34. end;
  35.  

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.
« Last Edit: February 21, 2021, 07:39:41 am by egsuh »

circular

  • Hero Member
  • *****
  • Posts: 4221
    • Personal webpage
Re: Can anybody verify this?
« Reply #1 on: February 21, 2021, 06:45:55 am »
Seems more like a server-side error.
Conscience is the debugger of the mind

egsuh

  • Hero Member
  • *****
  • Posts: 1296
Re: Can anybody verify this?
« Reply #2 on: February 21, 2021, 07:39:16 am »
Quote
Seems more like a server-side error.

Yes. You are right. I found out the reason. Webserver could not write to "c:\windows\temp" directory. I could find this by setting host to localhost, not alphaq.codns.com.  alphaq.codns.com showed just 500 error, but localhost sent out something similar to  "failure to write to c:\windows\temp\CGI000~%...", so I set the privileges of that folder to read and write for users and iis_iusers.
Still I don't know why suddenly this error happened. One possible reason may be the privileges might have been changed during auto-Windows upgrade or any other installation of applications, but not sure of course.

 

TinyPortal © 2005-2018