Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread ServerRequest and wrongly produce URL
Tue, Feb 28 2017 3:53 PMPermanent Link

Mario Enríquez

Open Consult

Hi folks,

The URL formed by ServerRequest it getting somewhat messed at the web server. Any idea?

When the following piece of code is run...

var
 appctx : string;
 IdComplejo: string;
begin
  ServerRequest1.URL := 'http://localhost:8080/Multidomus/GetEntidades';
  
  appctx := 'DEV01';
  IdComplejo := '{5E54D885-B866-4725-990E-E78CC976C1E5}';

  ServerRequest1.Params.Add('pAppCtx=' + appctx);
  ServerRequest1.Params.Add('pId=' + IdComplejo);
  ServerRequest1.Execute;
end;

The following url is received at the server side...

http://localhost:8080/Multidomus/GetEntidades?pAppCtx%3DDEV01&pId%3D%7B5E54D885-B866-4725-990E-E78CC976C1E5%7D

As you can probable notice, the equal sign in each parameter it been substitute  for a '%3D' , and the opening and closing curly braces on the GUID value.

The behaviour is breaking the server code down, because its breaking down the params parsing...

If I write down the URL in the browser address bar, everything works as expected..

am I missing something on the EWB side?

Regards,
Mane
Wed, Mar 1 2017 12:00 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mario,

<< The URL formed by ServerRequest it getting somewhat messed at the web server. Any idea? >>

Yes, this is a bug.  Here is the hot fix:

Replace this method in the WebHTTP unit:

procedure TServerRequest.Execute;
{$IFNDEF DESIGN}
var
  I: Integer;
  TempURL: String;
{$ENDIF}
begin
  {$IFNDEF DESIGN}
  try
     TempURL:=encodeURI(FURL);
     if (FParams.Count > 0) then
        begin
        TempURL:=TempURL+'?'+FParams.Names[0]+'='+encodeURIComponent(FParams.ValueFromIndex[0]);
        for I:=1 to FParams.Count-1 do
           TempURL:=TempURL+'&'+FParams.Names[I]+'='+encodeURIComponent(FParams.ValueFromIndex[I]);
        end;
     FHttpRequest.open(MethodName,TempURL,True,FUserName,FPassword);
     for I:=0 to FRequestHeaders.Count-1 do
        begin
        if (FRequestHeaders.Names[I] <> '') then
           FHttpRequest.setRequestHeader(Trim(FRequestHeaders.Names[I]),
                                         Trim(FRequestHeaders.ValueFromIndex[I]));
        end;
     FHttpRequest.timeout:=FTimeout;
     FHttpRequest.send(FRequestContent.Text);
  except
     on E: Exception do
        raise Exception.Create(Translate('ERR_HTTP_REQUEST',[FURL,E.Message]));
  end;
  {$ENDIF}
end;

The fix itself will be in 2.06 (next beta, also).

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Mar 1 2017 8:15 AMPermanent Link

Mario Enríquez

Open Consult

Great Tim, thank you.

Regards,
Mario
Wed, Mar 1 2017 7:23 PMPermanent Link

Mario Enríquez

Open Consult

Tim,

I just tried the HotFix you provided and the handling the equal sign is working fine now. However this curly braces enclosing the GUID value, is still getting messed up.

Is the normal behaviour for URL encoding?


Regards,
Mario
Thu, Mar 2 2017 3:54 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mario,

<< Is the normal behaviour for URL encoding? >>

Yes:

http://meta.stackexchange.com/questions/79057/curly-brackets-in-urls

Tim Young
Elevate Software
www.elevatesoft.com
Image