Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread Trying to call a EWB app, but empty Request
Thu, Aug 25 2022 5:37 PMPermanent Link

Ralf Mimoun

Hi,

I just wrote a very simple EWB server app for testing purpose, ultimately I want to send JSON. But there are problems, so... All it does is a

Request.SendContent(Request.RequestHeaders.Text + '#' + Inttostr(request.RequestContentLength)+'#'+request.RequestContent);

in the TMainReqHandler.MainReqHandlerHandleRequest - more or less an echo of the stuff the client sends.

The caller is a EWB client app, calling the server with this code:

 srLastModifiedAt.Content.Clear;
 srLastModifiedAt.Content.Add('Test');
 srLastModifiedAt.Headers.Clear;
 srLastModifiedAt.Headers.Values[HTTP_HEADER_CONTENT_TYPE] := 'application/json; charset=utf-8';
 srLastModifiedAt.Headers.Values[HTTP_HEADER_CONTENT_LENGTH] := IntToStr(Length(srLastModifiedAt.Content.Text));
 srLastModifiedAt.URL := MyURL;
 srLastModifiedAt.Execute;

Method is rmGet, all good. In srLastModifiedAtComplete I can see what's coming back. HTTP code is 200, and the server app got tons of browser infos, so all good. RequestHeaders look good, too, except that "Content-Length" is missing. And RequestContent is empty.

But: the Headers (srLastModifiedAt.Headers.Text in srLastModifiedAtComplete ) look fine at the client side. I have not the faintest idea why nothing is received by the server app. What do I miss?
Thu, Aug 25 2022 8:09 PMPermanent Link

erickengelke

Avatar

Ralf Mimoun wrote:
> I just wrote a very simple EWB server app for testing purpose, ultimately I want to send JSON.
>...
>Method is rmGet, all good.

Set method := mrPost and it should work I think.

Erick
EWB Programming Books and Component Library
http://www.erickengelke.com
Fri, Aug 26 2022 2:32 AMPermanent Link

Ralf Mimoun

YES! Thanks! I tried to send some kind of credentials (temporary token + client id) in the payload to the server. Seems to be a bad idea, so I'll put it in the url parameters.

erickengelke wrote:

Ralf Mimoun wrote:
> I just wrote a very simple EWB server app for testing purpose, ultimately I want to send JSON.
>...
>Method is rmGet, all good.

Set method := mrPost and it should work I think.

Erick
EWB Programming Books and Component Library
http://www.erickengelke.com
Fri, Aug 26 2022 8:58 AMPermanent Link

erickengelke

Avatar

Ralf Mimoun wrote:

YES! Thanks! I tried to send some kind of credentials (temporary token + client id) in the payload to the server. Seems to be a bad idea, so I'll put it in the url parameters.

erickengelke wrote:

Ralf Mimoun wrote:
> I just wrote a very simple EWB server app for testing purpose, ultimately I want to send JSON.
>...
>Method is rmGet, all good.

Set method := mrPost and it should work I think.

Erick
EWB Programming Books and Component Library
http://www.erickengelke.com
EWB Programming Books and Component Library
http://www.erickengelke.com
Fri, Aug 26 2022 9:01 AMPermanent Link

erickengelke

Avatar

erickengelke wrote:

Ralf Mimoun wrote:

> YES! Thanks! I tried to send some kind of credentials (temporary token + client id) in the payload to the server. >Seems to be a bad idea, so I'll put it in the url parameters.

Post is generally safer.  It doesn't get logged, and you can send more data.  URL parameters are limited in the number of bytes that can be transferred on the URL line, whereas POST data size is unlimited.

Erick
EWB Programming Books and Component Library
http://www.erickengelke.com
Fri, Aug 26 2022 9:01 AMPermanent Link

erickengelke

Avatar

erickengelke wrote:

Ralf Mimoun wrote:

> YES! Thanks! I tried to send some kind of credentials (temporary token + client id) in the payload to the server. >Seems to be a bad idea, so I'll put it in the url parameters.

Post is generally safer.  It doesn't get logged, and you can send more data.  URL parameters are limited in the number of bytes that can be transferred on the URL line, whereas POST data size is unlimited.

Erick
EWB Programming Books and Component Library
http://www.erickengelke.com
Fri, Aug 26 2022 9:01 AMPermanent Link

erickengelke

Avatar

erickengelke wrote:

Ralf Mimoun wrote:

> YES! Thanks! I tried to send some kind of credentials (temporary token + client id) in the payload to the server. >Seems to be a bad idea, so I'll put it in the url parameters.

Post is generally safer.  It doesn't get logged, and you can send more data.  URL parameters are limited in the number of bytes that can be transferred on the URL line, whereas POST data size is unlimited.

Erick
EWB Programming Books and Component Library
http://www.erickengelke.com
Fri, Aug 26 2022 5:44 PMPermanent Link

Ralf Mimoun

I started this project with data access via client. But safety is a real issue here, so I do some stuff to get only the data to the client that the user is allowed to see. Nonetheless, the app is logged into the server with some privileges regarding data modifications.

So, I am switching to nice REST APIs, implemented as a server app. No access to the database from the client whatsoever. That means that I try to follow the REST rules, with GET/PUT (no need for POST/DELETE in this project), entity etc. That means that I have to use GET. Btw, it works great! Of course, it is easier to define REST APIs with eg. .Net than EWB, but I only need a andful more lines. Easy peasy.


erickengelke wrote:

erickengelke wrote:

Ralf Mimoun wrote:

> YES! Thanks! I tried to send some kind of credentials (temporary token + client id) in the payload to the server. >Seems to be a bad idea, so I'll put it in the url parameters.

Post is generally safer.  It doesn't get logged, and you can send more data.  URL parameters are limited in the number of bytes that can be transferred on the URL line, whereas POST data size is unlimited.

Erick
EWB Programming Books and Component Library
http://www.erickengelke.com
Image