RTC Forums

Subscription => Support => Topic started by: xstarter on April 27, 2012, 09:20:56 AM



Title: Little changes in rtcSocketHttpSrvProv.pas
Post by: xstarter on April 27, 2012, 09:20:56 AM
Hello Danijel,

I changed a little code in the topic unit. Can you add this changes in your version, please?

Was:
Code:
procedure TRtcSocketHttpServerProvider.TriggerDataSent;
  begin
  if Response.Sending then
    begin
    if not Response.Done then
      Response.Done := LenToSend=0;

Now:
Code:
procedure TRtcSocketHttpServerProvider.TriggerDataSent;
  begin
  if Response.Sending then
    begin
    if not Response.Done then
      Response.Done := LenToSend<=0;

Sometimes I have LenToSend=-1, but Response after this still not Done, so my change helps. Thank you.


Title: Re: Little changes in rtcSocketHttpSrvProv.pas
Post by: D.Tkalcec (RTC) on April 27, 2012, 12:00:36 PM
That change would break HTTP/1.0 and streaming functionality, where content length is NOT specified and LenToSend will be -1 until the connection is closed. If you are getting into situations where LenToSend=-1, but you are NOT using HTTP/1.0 or streaming without explicitly setting ContentLength, it means that there is an error somewhere else.

Best Regards,
Danijel Tkalcec


Title: Re: Little changes in rtcSocketHttpSrvProv.pas
Post by: D.Tkalcec (RTC) on April 27, 2012, 01:00:50 PM
Instead of making the change you've made, I would recommend adding a check after Dec(LenToSend,DataOut) in the TriggerDataOut method inside the same unit (rtcSocketHttpSrvProv.pas):

Code:
procedure TRtcSocketHttpServerProvider.TriggerDataOut;
  var
    nmd:boolean;
  begin
  nmd:=False;

  Response.Started:=False;
  if LenToSend>=0 then
    begin
    Dec(LenToSend, DataOut);
    if LenToSend<0 then
      raise Exception.Create('FATAL ERROR in TRtcSocketHttpServerProvider: More Data Out than Data Sent?');
    end;

  if LenToSend=0 then
    nmd:=(InBuffer='') and not Request.Close;

  inherited TriggerDataOut;

  if nmd then
    NeedMoreData;
  end;

If that exception does happen in your Project, then I will need an example Project which demonstrates the issue, with instructions on how to reproduce it, so I can perform my own tests to find out what is wrong.

Best Regards,
Danijel Tkalcec


Title: Re: Little changes in rtcSocketHttpSrvProv.pas
Post by: D.Tkalcec (RTC) on April 27, 2012, 01:19:17 PM
In addition to the example project, I also need to know which platform you are compiling the project for (Win32, Win64, OSX, iOS emulator or iOS device) and which compiler you are using.

Best Regards,
Danijel Tkalcec


Title: Re: Little changes in rtcSocketHttpSrvProv.pas
Post by: D.Tkalcec (RTC) on May 03, 2012, 06:46:41 PM
RTC SDK v5.16 is now ready for download, with improved "LenToSend" overflow checking, as well as debug logging for any unexpected "DataOut" or "LenToSen" conditions (just declare the "RTC_DEBUG" compiler directive). Should you have problems with the "LenToSend" counter going below zero when using the "RTC SDK v5.16" update (without your modifications), then I will need an example Project for testing, because this is definitely not normal behavior.

Best Regards,
Danijel Tkalcec