EldoS | Feel safer!

Software components for data protection, secure storage and transfer

HTTP(S) Demo to Do POST

Also by EldoS: Solid File System
A virtual file system that offers a feature-rich storage for application documents and data with built-in compression and encryption.
#22506
Posted: 11/16/2012 10:26:03
by Angel Sala (Basic support level)
Joined: 11/16/2012
Posts: 1

Hello,
I'm learning on this topic, so I changed the HTTP(S)Server Demo to deal whith POST, using SSL. I`d also used HTTPBlackBox File Upload Demo (SSL) to upload a text file (100 bytes). The code changed(Server) is simple, and follows:
Code
procedure THTTPSServerThread.ProcessRequest;
var
  ..
begin
  FCurrentResponse.UseChunkedTransfer := FUseChunkedTransfer;
  FCurrentResponse.UseKeepAlive := FCurrentRequest.KeepAlive;
  UseKeepAlive := FCurrentRequest.KeepAlive;

  // turn off internal server compression if chunked encoding is disabled
  FCurrentResponse.UseCompression := FUseCompression and FUseChunkedTransfer;
  CompressionEnabled := FUseCompression;

  // process only GET requests
  if FCurrentRequest.Method = hmGet then
  begin
    ... not changed
  end
.. new code
  else if (FCurrentRequest.Method = hmPost) and (SameText(FCurrentRequest.URL, '/upload')) then
  begin
    try
      N := Now;
      DecodeDate(N, YY, MM, DD);
      DecodeTime(N, H, M, S, MI);
      FileName := URLRemoveSlash(FBasePath) + FCurrentRequest.URL + Format('%.4d%.2d%.2d%.2d%.2d%.2d.upl', [YY, MM, DD, H, M, S]);
      FFile := TFileStream.Create(FileName, fmCreate or fmShareDenyWrite);
      MS := TMemoryStream.Create;
      try
        //FHTTPSServer.ParseMultipartFormData(FCurrentRequest,FFile);
        FHTTPSServer.ParseMultipartFormData(FCurrentRequest,MS);
      finally
        FreeAndNil(FFile);
      end;
  ...
end


The problem is that when FHTTPSServer.ParseMultipartFormData(FCurrentRequest,MS); executes, a exception is raised: "Error parsing Multipart/form-data content. I`m willing to use Blackbox components and not de Indy ones used on other Demos.

Thanks,
#22525
Posted: 11/19/2012 01:19:32
by Vsevolod Ievgiienko (EldoS Corp.)

Thank you for contacting us.

Please use <code> tag for your code.

The HTTPPost sample must be used only with simple_upload.php script, but not with our HTTPSServer sample. You should modify both samples to make them compatible.

Also your changes are incorrect. You are trying to parse an empty TMemoryStream. Please study the server sample - it already contains a sample of POST processing.
#34046
Posted: 07/16/2015 05:17:22
by Raffaele Picone (Standard support level)
Joined: 07/14/2015
Posts: 2

I'm seraching for such server example implementing the post method since a week without success. How I can have this example. Is very urgent !!!!
#34047
Posted: 07/16/2015 05:22:06
by Eugene Mayevski (EldoS Corp.)

Raffaele, you asked this question in the another topic, and I gave you an answer there. You asked in the HelpDesk, and I answered there. Please do read the answers to your questions - this will help you get timely support.


Sincerely yours
Eugene Mayevski

Reply

Statistics

Topic viewed 1949 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!