RTC Forums
November 24, 2024, 01:27:10 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Filenames with spaces (%20)  (Read 6027 times)
Dany
RTC License++
*****
Posts: 69


« on: March 20, 2015, 04:56:56 PM »

I was under the impression that an URL could contain stuff like %20 for a space and other encoded characters.

The request
http://localhost/searchdownload/Files%20for%20Me.zip
however comes in with Request.FilePath[1] equaling "Files".

In rtcSocketHttpSrvProv.pas (using v6.48) i can see the parsing of the FileName uses a space:
Code:
              // Request FileName
              MyPos:=PosEx(' ',StatusLine);
              if MyPos<=0 then
                begin
                Request.FileName:=StatusLine;
                RequestError;
                Exit;
                end;

              Request.FileName:=Copy(StatusLine,1,MyPos-1);
              Delete(StatusLine,1,MyPos);

At this time the StatusText looks like this:
'/searchdownload/Files for Me.zip HTTP/1.1'

(Note: FixupRequest does not seem to be related to this).

Please correct and excuse me if i have run into one of these clouds of confusion - it's cloudy and we just had a solar eclipse  Cheesy.

TIA,

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


« Reply #1 on: March 20, 2015, 09:20:13 PM »

If the StatusText variable on the Server side contains spaces and not the expected %20 escape sequence, then the Client is sending the space character instead of %20, which means that the problem is on the Client side. The Client needs to URL_Encode the Request.FileName before sending it to the Server if the FileName contains special characters like space.

What are you using as a Client?

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


« Reply #2 on: March 21, 2015, 11:25:50 AM »

I typed the line
http://localhost/searchdownload/Files%20for%20Me.zip
into Chrome.
Logged
D.Tkalcec (RTC)
Administrator
*****
Posts: 1881


« Reply #3 on: March 21, 2015, 01:12:01 PM »

I can not reproduce the problem you are describing using the latest RTC SDK version (6.48). Looking at the code and testing with Delphi 7 (oldest version supported) as well as Delphi XE7 (latest version supported), everything works as expected and I see no reason how this could be happening, when the Client is sending the correct request. As far as I ca see, there are no bugs in RTC code responsible for parsing the URL and Google Chrome is not messing anything up, so ... the problem must be somewhere else.

When I enter the URL http://localhost/searchdownload/Files%20for%20Me.zip in Google Chrome, I get the following results ...

If FixupRequest.DecodeFileName = FALSE:
Request.FileName = '/searchdownload/Files%20for%20Me.zip'
Request.FilePath[0] = 'searchdownload'
Request.FilePath[1] = 'Files%20for%20Me.zip'

And if FixupRequest.DecodeFileName = TRUE:
Request.FileName = '/searchdownload/Files for Me.zip'
Request.FilePath[0] = 'searchdownload'
Request.FilePath[1] = 'Files for Me.zip'

Are you 100% sure you have analyzed the problem correctly? Did you run tests with a simple Server using only one TRtcHttpServer and one TRtcDataProvider component to see what happens, or are you making assumptions based on the results you get in a more complex Project? Please, open the example Project in the QuickStart\ServerLesson1 folder and modify the RtcDataProvider1CheckRequest event to use this code ...

  with Sender as TRtcDataServer do
    ShowMessage(Request.FilePath[1]);

... then run the Project, enter the URL http://localhost/searchdownload/Files%20for%20Me.zip in Google Chrome and tell me what you see in the ShowMessage dialog box. It should be "Files for Me.zip", because the FixupRequest.DecodeFileName property on the RtcHttpServer1 component defaults to TRUE in that example. And if you change the FixupRequest.DecodeFileName property to FALSE and restart the Project, you should see "Files%20for%20Me.zip" instead when the same request is sent from Google Chrome.

Also ... please, let me know which Delphi version you are using and what is your target platform.

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


« Reply #4 on: March 21, 2015, 01:15:19 PM »

Thank you for your prompt and well made response.
I am not at site now but will follow your suggestions and do a better analysis of what is going on.

Kind regards,

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


« Reply #5 on: March 21, 2015, 01:19:02 PM »

Ok. Please, keep me posted on your test results.

If there is any kind of a problem in the RTC SDK, I would like to know about it, so I can fix it.

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


« Reply #6 on: November 18, 2015, 01:08:10 PM »

Life takes us somewhere else sometimes... anyway.

This was due to FixupRequest.DecodeFileName was set to TRUE for a TRtcHttpServer being linked from a datamodule containing TRtcDataRouter component(s). And as is often the case using RTC it says in the docs that this setting should be FALSE in these cases.

Case so closed. Where's the icon for feeling stupid?


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


« Reply #7 on: November 18, 2015, 01:18:50 PM »

Thank you for your feedback.

PS. "Life is what happens while you are busy making other plans" Smiley

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.027 seconds with 16 queries.