RTC Forums
May 08, 2024, 03:28:26 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Little changes in rtcSocketHttpSrvProv.pas  (Read 3839 times)
xstarter
RTC Expired
*
Posts: 8


« 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.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 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
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #2 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
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 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
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #4 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
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.023 seconds with 16 queries.