blitz-foundation / monkey2

zlib License
3 stars 0 forks source link

httprequest issues #115

Open Pharmhaus-2 opened 5 years ago

Pharmhaus-2 commented 5 years ago

Original Author: jondecker76

wget is returning an exit status of 8 (error) on my POST request and the response text is not being set.

cmd string when copied from the console runs fine in the terminal under linux and a response is received, but for some reason there is an error within monkey2 and the response isn't received.

This test demonstrates the issue:

Namespace myapp

#Import "<std>"
#Import "<mojo>"
#Import "<mojox>"
#Import "<httprequest>"

Using std..
Using mojo..
Using mojox..
Using httprequest..

Class MyWindow Extends Window

    Method New( title:String="HttpRequest demo",width:Int=640,height:Int=480,flags:WindowFlags=Null )

        Super.New( title,width,height,flags )

        Layout="letterbox"      

        Local label:=New Label

        Local req:=New HttpRequest

        req.Timeout=10

        req.ReadyStateChanged=Lambda()

            label.Text="Ready state changed to "+Int( req.ReadyState )+" status="+req.Status

            If req.ReadyState=ReadyState.Done Print "Request response:~n"+req.ResponseText
        End

        Const url:="https://mws.amazonservices.com/Sellers/2011-07-01"

        req.Open( "POST",url )

        Local button:=New Button( "CANCEL!" )

        button.Clicked+=Lambda()

            req.Cancel()
        End

        Local dockingView:=New DockingView

        dockingView.AddView( label,"top" )

        dockingView.ContentView=button

        ContentView=dockingView

        req.Send("Action=GetServiceStatus")
    End

    Method OnRender( canvas:Canvas ) Override

        App.RequestRender() 'need this for ios?
    End

    Method OnMeasure:Vec2i() Override

        Return New Vec2i( 320,240 )
    End

End

Function Main()

    New AppInstance

    New MyWindow

    App.Run()
End

here is the command string that ends up being generated internally, and it runs fine from the linux command line: wget -q -T 10 -O "/tmp/mx2_wget-1.txt" --method="POST" --body-data="Action=GetServiceStatus" "https://mws.amazonservices.com/Sellers/2011-07-01"