RTC Forums
November 24, 2024, 04:36:17 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Login Register  
Pages: [1]
  Print  
Author Topic: Dummy question: read POST data from onDataReceived event  (Read 4343 times)
Nanosystems
RTC License++
*****
Posts: 9


« on: September 04, 2013, 02:23:19 PM »

Hi, i have a client calling my server posting 2 parameters inside POST data (not querystring), and i need to read it. Now here how my code works:

Code:
procedure TForm6.RtcDataProvider1DataReceived(Sender: TRtcConnection);
var
    vsFileName : string; //(1)
    viFileSize : integer;
    readString : string;
begin
  readString := (sender as TRtcConnection).read();
  with TRtcDataServer(Sender) do //(2)
    if Request.Complete then
    begin
      write('Test1: ' + Request.Info['param1'] + ', Test2: ' + Request.Params.Value['param1'] + ', readString: ' + readString);
    end;
end;

it's just an edited example! I can read the full POST data inside readString, but i don't have an object to call the single parameters, something like "myObject['param1']".
i tried to read the "param1" parameter in some ways but i always got an empty string, those in the code are just 2 of my tries.

Does RealThinClient provide some already working object to encapsulate and read POST data?
Logged
Kevin Powick
RTC Expired
*
Posts: 87


« Reply #1 on: September 04, 2013, 02:44:02 PM »

Just going by memory, but I think that all you need to do is populate the Params.

See added line in modified code sample below.

Code:
procedure TForm6.RtcDataProvider1DataReceived(Sender: TRtcConnection);
var
    vsFileName : string;
    viFileSize : integer;
    readString : string;
begin
  readString := (sender as TRtcConnection).read();
  with TRtcDataServer(Sender) do
    if Request.Complete then
    begin
      Request.Params.AddText(readString); // <--- LOAD PARAMS  
      write('Test1: ' + Request.Params.Value['param1'] + ', readString: ' + readString);
    end;
end;
Logged

Linux is only free if your time is worthless
Nanosystems
RTC License++
*****
Posts: 9


« Reply #2 on: September 04, 2013, 05:00:26 PM »

thank you, it works flawlessly Smiley
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.024 seconds with 17 queries.