PowerBuilder
PowerBuilder
Transition from Http.PostUrlEncoded to Http.HttpReq
Provides instructions for replacing deprecated PostUrlEncoded method calls with HttpReq.Sends the following raw HTTP request:
POST /echoPost.asp HTTP/1.1 Host: www.chilkatsoft.com Content-Type: application/x-www-form-urlencoded Content-Length: 50 company=example&ip=111.111.111.111&url=example.com
Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Http
string ls_Url
oleobject loo_Req
oleobject loo_ResponseObj
oleobject loo_Req2
oleobject loo_Resp
li_Success = 0
loo_Http = create oleobject
li_rc = loo_Http.ConnectToNewObject("Chilkat.Http")
if li_rc < 0 then
destroy loo_Http
MessageBox("Error","Connecting to COM object failed")
return
end if
ls_Url = "https://www.chilkatsoft.com/echoPost.asp"
loo_Req = create oleobject
li_rc = loo_Req.ConnectToNewObject("Chilkat.HttpRequest")
loo_Req.AddParam("company","example")
loo_Req.AddParam("ip","111.111.111.111")
loo_Req.AddParam("url","example.com")
// ------------------------------------------------------------------------
// The PostUrlEncoded method is deprecated:
loo_ResponseObj = loo_Http.PostUrlEncoded(ls_Url,loo_Req)
if loo_Http.LastMethodSuccess = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_Req
return
end if
// ...
// ...
destroy loo_ResponseObj
// ------------------------------------------------------------------------
// Do the equivalent using HttpReq.
// Your application creates a new, empty HttpResponse object which is passed
// in the last argument and filled upon success.
loo_Req2 = create oleobject
li_rc = loo_Req2.ConnectToNewObject("Chilkat.HttpRequest")
loo_Req2.AddParam("company","example")
loo_Req2.AddParam("ip","111.111.111.111")
loo_Req2.AddParam("url","example.com")
loo_Req2.HttpVerb = "POST"
loo_Req2.ContentType = "application/x-www-form-urlencoded"
loo_Resp = create oleobject
li_rc = loo_Resp.ConnectToNewObject("Chilkat.HttpResponse")
li_Success = loo_Http.HttpReq(ls_Url,loo_Req2,loo_Resp)
if li_Success = 0 then
Write-Debug loo_Http.LastErrorText
destroy loo_Http
destroy loo_Req
destroy loo_Req2
destroy loo_Resp
return
end if
// Results are contained in the HTTP response object...
destroy loo_Http
destroy loo_Req
destroy loo_Req2
destroy loo_Resp