Sample code for 30+ languages & platforms
Xbase++ Requires Chilkat v11.0.0+

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 Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oHttp
LOCAL cUrl
LOCAL oReq
LOCAL oResponseObj
LOCAL oReq2
LOCAL oResp

nSuccess := 0

oHttp := CreateObject("Chilkat.Http")

cUrl := "https://www.chilkatsoft.com/echoPost.asp"

oReq := CreateObject("Chilkat.HttpRequest")
oReq:AddParam("company", "example")
oReq:AddParam("ip", "111.111.111.111")
oReq:AddParam("url", "example.com")

//  ------------------------------------------------------------------------
//  The PostUrlEncoded method is deprecated:

oResponseObj := oHttp:PostUrlEncoded(cUrl, oReq)
IF (oHttp:LastMethodSuccess == 0)
    ? oHttp:LastErrorText
    oHttp:destroy()
    oReq:destroy()
    RETURN
ENDIF

//  ...
//  ...

oResponseObj:destroy()

//  ------------------------------------------------------------------------
//  Do the equivalent using HttpReq.
//  Your application creates a new, empty HttpResponse object which is passed 
//  in the last argument and filled upon success.

oReq2 := CreateObject("Chilkat.HttpRequest")
oReq2:AddParam("company", "example")
oReq2:AddParam("ip", "111.111.111.111")
oReq2:AddParam("url", "example.com")

oReq2:HttpVerb := "POST"
oReq2:ContentType := "application/x-www-form-urlencoded"

oResp := CreateObject("Chilkat.HttpResponse")
nSuccess := oHttp:HttpReq(cUrl, oReq2, oResp)
IF (nSuccess == 0)
    ? oHttp:LastErrorText
    oHttp:destroy()
    oReq:destroy()
    oReq2:destroy()
    oResp:destroy()
    RETURN
ENDIF

//  Results are contained in the HTTP response object...

oHttp:destroy()
oReq:destroy()
oReq2:destroy()
oResp:destroy()