RTC Forums
May 20, 2024, 04:34:41 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Some Router problem with ETag and empty payload  (Read 3818 times)
Dany
RTC License++
*****
Posts: 69


« on: July 14, 2017, 01:27:09 PM »

Hello!

I am not sure if i can do what i want  Wink but here goes a reproduction instruction (this is using RTC 8.17):

The FileServer Demo

1. Change listening port to 90.
2. Insert the following code into the rtcFileProvider.pas file @483 (before the "if Request.Method = 'HEAD' in the CheckDiskFile procedure body...):
Code:
          Response['ETag'] := '"' + MyFileName + '"';
          if Request['If-None-Match'] = Response['Etag'] then
          begin
            Response.SendContent := false;
            Response.Status(304, 'Not modified');
          end;
3. Compile, execute and start FileServer Demo and access localhost:90/index.htm (i use Chrome).

The first request is answered with 200 and the text appears. OK!
If i press Ctrl+R another response with status 200 is delivered. OK!
If i click the reload button or press enter in the address field a response with status 304 is received. OK!
All good.

The RTCRouter2 Demo

4. Compile and execute the up the RTCRouter2 Demo.
5. Set Server Address to localhost and Server Port to 90.
6. Start the router.
6. Access the FileServer Demo (still running) using localhost/index.htm (i still use Chrome).

The first response is delivered with status 200 and i can see the text. OK.
I click the reload button and one response with status 304 is received. OK.

However, when i continuously click the reload button the next request get stuck and (pending) is shown in Chromes Network debugger panel. FAIL?

TIA for any insights!

/Dany
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #1 on: July 14, 2017, 05:30:21 PM »

Thank you for reporting this problem and for providing a clear step-by-step guide to reproduce it.

I've released an update now (RTC SDK v8.18) to fix the problem and eliminate the need for manually setting the Response.SendContent property to FALSE when preparing a Response which SHOULD NOT HAVE a Content Body. This includes all responses to 'HEAD' requests, as well as responses with a Status Code 1xx, 204 and 304.

Please, download the update and let me know if the problem is now fixed (or not?).

Best Regards,
Danijel Tkalcec
Logged
Dany
RTC License++
*****
Posts: 69


« Reply #2 on: July 14, 2017, 07:21:18 PM »

Yes!

I have even updated the deployed router - server and it works nicely now Smiley [Though it will not give much feedback-wise since the load is rather meagre there atm].

Making a good MVE is a breeze when i do not forget to try the problem out in the Demos. The Demos (they are very complete and extensive) are really good like that. I guess the only downside is the learning curve for new users.

Before thinking of trying out my problem using the demos i was tracing along heavily. I noticed that i got some hidden exceptions (Trying to send more data out...) from the server behind the router and i think this was because i used Write *with* content even if SendContent was set to false. I also try to handle empty files / payloads like non-empty files / payloads (this is not the case in the webserver demo) because an E-Tag i suppose is valid for an empty file / response too.

I will, however, revisit that code and get more into those cases when i put E-Tags on my REST responses too. I'll also try to remove some now redundant calls.

Thank you *so much* for this prompt response.

/Dany

Regards
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 on: July 14, 2017, 07:58:13 PM »

Perfect. Thanks again for your feedback.

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.026 seconds with 17 queries.