Aloe Problem with Curl Post Due to "Expect: 100-continue"

  1. 8 months ago

    Brandon W

    11 Apr 2019 Pre-Release Testers, Xojo Pro Texas, USA

    We have a API that we are testing with Aloe 4.1, When sending a Post request with Postman, it seems to work fine. But, when sending a Post request with the Monkeybread Curl plugin from another Xojo app, Aloe seems to be firing the DataAvailable event twice in Aloe. And when this happens, it seems to be running Request.Prepare twice (one for each DataAvailable event that fires). The second "prepare" is corrupting the results that are returned. I don't know the code that well yet, but it seems there could be a bug when a second DataAvailable event is fired. The DataReceivedCount integer variable is never more than 1. Should it be?

  2. Tim D

    12 Apr 2019 Pre-Release Testers, Xojo Pro, XDC Speakers

    Hi @Brandon W.

    I will need to see the code in the other Xojo app - the one that's calling the Aloe-based API - in order to help you with this.

    - Tim

  3. Brandon W

    12 Apr 2019 Pre-Release Testers, Xojo Pro Texas, USA

    We figured it out and changed the subject of this post. When sending a POST request with curl it sometimes automatically adds an "Expect: 100-continue" header and the Aloe server does not support this. It was hard to figure out because it only adds the header if the request is a POST and the content is over 1024 bytes. So, when we were testing, it would work sometimes and not others due to the amount of sample data we were trying at the time.

    The header can be prevented by simply setting "Expect:" to nothing before posting with the curl plugin:

    Curl.SetOptionHTTPHeader(Array("Expect:"))

    Following is a good description:
    https://gms.tf/when-curl-sends-100-continue.html

    Maybe this will help someone else!

  4. Christian S

    12 Apr 2019 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    Expect is something used with HTTP 1.1 to get a confirmation of server for the transfer before sending data. If you'd get a permission denied right away, you would not send data.

  5. Brandon W

    12 Apr 2019 Pre-Release Testers, Xojo Pro Texas, USA
    Edited 8 months ago

    You are correct Christian, it is useful in some cases for a server to prevent a client from sending a large post. However, I dont think Aloe is compatible with this ... so not using it solved our issue, partly... see next post...

  6. Brandon W

    12 Apr 2019 Pre-Release Testers, Xojo Pro Texas, USA

    After figuring out the above issue, we are still having a problem posting a large amount of data. We have a post with content of 2,001,810 bytes and Aloe is choking on it. I think it is in Request.DataAvailable event on line 60.

    The original code is :

    If ContentReceivedLength <  Lookahead.LenB Then

    I suspect it needs to be:

    If ContentReceivedLength <  ContentLength Then

    Changing it seems to have solved the issue but I am not sure if it could cause other problems. Maybe @Tim D can look into it.

  7. Brandon W

    12 Apr 2019 Pre-Release Testers, Xojo Pro Texas, USA

    One more thing. Aloe is choking on this post request using Postman and the Curl plugin from a Xojo app. That is what leads me back to thinking it is an Aloe issue.

  8. 7 months ago

    Jürg O

    6 May 2019 Pre-Release Testers, Xojo Pro

    @Brandon W I suspect it needs to be:

    If ContentReceivedLength <  ContentLength Then

    Changing it seems to have solved the issue but I am not sure if it could cause other problems. Maybe @Tim Dietrich can look into it.

    fwiw: after updating to the latest official/public Aloe Express, we had to change this back to how it has been before, too.
    We've also noticed issues when processing POST requests (Aloe.Request not firing at all, or too many times). Changing this line back to If ContentReceivedLength < ContentLength Then has also solved the issues we've noticed.

  9. Karen A

    6 May 2019 Pre-Release Testers

    I have not tried a file upload yet, but I noticed that in the DataAvailable event and will change that...

    I also noticed that in that event it checks for max content length and that is set to about 1MB... Does that means file uploads with multiple forms would be be limited to less than 1MB?

    If so, would there be an issue with raising the limit (I think I will need to occasionally to do much larger files). The comment say the limit is there to stop bad actors .... so maybe better would be if there was a way to up the limit for verified user... Is that supported?

  10. Derk J

    6 May 2019 Pre-Release Testers, Xojo Pro

    @Jürg O fwiw: after updating to the latest official/public Aloe Express, we had to change this back to how it has been before, too.
    We've also noticed issues when processing POST requests (Aloe.Request not firing at all, or too many times). Changing this line back to If ContentReceivedLength < ContentLength Then has also solved the issues we've noticed.

    That’s correct. The content wasn’t handled properly. This should fix it for you.

  11. Tim D

    7 May 2019 Pre-Release Testers, Xojo Pro, XDC Speakers

    I posted this in another thread, but thought I'd post it here as well...

    The bug that was introduced in Aloe Express 4.1.0, which caused issues with the processing of multi-part forms, has been resolved in the latest version Aloe Express 4.1.1. That version is available for download here: https://aloe.zone/resources/downloads.html

    This update rolls back the problematic changes that were introduced in 4.1.0.

or Sign Up to reply!