Skip to content
This repository has been archived by the owner on Jan 25, 2019. It is now read-only.

Can't get POST request data #163

Closed
Al-Muhandis opened this issue Nov 28, 2018 · 13 comments
Closed

Can't get POST request data #163

Al-Muhandis opened this issue Nov 28, 2018 · 13 comments
Assignees
Labels

Comments

@Al-Muhandis
Copy link

Al-Muhandis commented Nov 28, 2018

Can't get POST request data.

procedure TWebhookAction.Post;
var
  Msg: String; 
begin
  PostData:=HttpRequest.Content; // PostData is empty string!
... ... ...

Legacy app 4.0.0 with tardigrade. Debian. Post data is not fields, that is string JSON Data.
Before with THTTPDaemonBroker worked

@silvioprog
Copy link
Owner

Hello @Al-Muhandis . I'm not sure about you are using in the client-side, but it seems you just need to inform the content-type. For example, if you are using fphttpclient (FPC) or NetHTTPClient (Delphi), just:

YourClient.ContentType := 'application/json';

@silvioprog
Copy link
Owner

Additional info (that will be documented soon):

  • ARequest.IsPost = check if the HTTP method is POST, PUT, DELETE or OPTIONS.
  • ARequest.IsUploading = check if the client is sending data (HTML fields, payload data or uploaded files etc.) to the server.

@Al-Muhandis
Copy link
Author

Al-Muhandis commented Nov 28, 2018

Hello @Al-Muhandis . I'm not sure about you are using in the client-side, but it seems you just need to inform the content-type. For example, if you are using fphttpclient (FPC) or NetHTTPClient (Delphi), just:

YourClient.ContentType := 'application/json';
  1. Thank you, but I can not access the client, as it is a telegram server, and my webhook on my server, which listens to POST requests from the telegram API
  2. Yes, and the content type of the request it put up correctly. It is application/json. I had just checked.

@Al-Muhandis
Copy link
Author

Al-Muhandis commented Nov 28, 2018

Additional info (that will be documented soon):

* `ARequest.IsPost` = check if the HTTP method is `POST`, `PUT`, `DELETE` or `OPTIONS`.

* `ARequest.IsUploading` = check if the client is sending data (HTML fields, payload data or uploaded files etc.) to the server.

The procedure I have is performed inside the POST method, so it is unlikely there will be another. But in any case, I don't know where is a ARequest? There is a property HTTPRequest in TBrookAction, and HTTPRequest which does not contain these functions

@silvioprog
Copy link
Owner

Could you test it outside the webhook using curl --header "Content-Type: application/json" --request POST --data '{"abc":123}' -w "\n" http://your-host:<your-port>? Just to check if the problem is related to Brook or the environment.

@silvioprog
Copy link
Owner

The procedure I have is performed inside the POST method, so it is unlikely there will be another.

Good news: you can use any HTTP method in the Tardigrade broker. :-)

But in any case, I don't know where is a ARequest?

They are available in the request object of Brook 5+, however, in legacy apps, you can debug to check if IsPost is returning True here.

I've tested all features before releasing v4.0.0, but I'll retest them again tonight.

@Al-Muhandis
Copy link
Author

Could you test it outside the webhook using curl --header "Content-Type: application/json" --request POST --data '{"abc":123}' -w "\n" http://your-host:<your-port>? Just to check if the problem is related to Brook or the environment.

The same... Empty POST data in the request

@silvioprog
Copy link
Owner

Confirmed. I'm going to check it tonight and provide a patch fixing the problem. Thanks for reporting!

@silvioprog silvioprog self-assigned this Nov 28, 2018
@silvioprog silvioprog added the bug label Nov 28, 2018
@silvioprog
Copy link
Owner

silvioprog commented Nov 28, 2018

@Al-Muhandis , could you try this attached experimental patch? To apply it, download Brook here, the patch 0001 and 0002, so:

git apply 0001-Removes-redundant-configuration.patch
git apply 0002-Fix-issue-161-high-CPU-activity-in-Tardigrade-based-.patch
git apply 0003-Fix-issue-163-reported-by-Al-Muhandis.patch.txt

and rebuild your application again to test if it works.

It is experimental, but should work well.

0003-Fix-issue-163-reported-by-Al-Muhandis.patch.txt

@Al-Muhandis
Copy link
Author

Al-Muhandis commented Nov 28, 2018

@Al-Muhandis , could you try this attached experimental patch? To apply it, download Brook here, the patch 0001 and 0002, so:

git apply 0001-Removes-redundant-configuration.patch
git apply 0002-Fix-issue-161-high-CPU-activity-in-Tardigrade-based-.patch
git apply 0003-Fix-issue-163-reported-by-Al-Muhandis.patch.txt

and rebuild your application again to test if it works.

It is experimental, but should work well.

0003-Fix-issue-163-reported-by-Al-Muhandis.patch.txt

Thank You very much! I applied the 2nd patch even earlier. 3rd patch just now. Now everything works!

@Al-Muhandis
Copy link
Author

Al-Muhandis commented Nov 28, 2018

So now I can clarify that telegram plugin does not work with tardigrade broker without 3 patch for BF 4.0

@silvioprog
Copy link
Owner

Indeed. Tonight I'm going to do some tests and move this patch to here. :-)

@silvioprog
Copy link
Owner

Tonight I'm going to do some tests and move this patch to here.

Done! Thanks @Al-Muhandis ! 😃

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants