Archived Forum Post

Index of archived forum posts

Question:

Purebasic - HTTP CkHttp::ckSynchronousRequestAsyn, cant get the result

Dec 18 '15 at 03:41

Hi!

I cant get the response from an "async http request":

task.i = CkHttp::ckSynchronousRequestAsync(http,"testpage.com",80,0,req)

As a synchronous version, its not a problem: resp = CkHttp::ckSynchronousRequest(http,"testpage.com",80,0,req)

Can you please give me an example to get the response from the webserver, not just the status code, if its called asynch?

Thanks Andrew Room


Accepted Answer

Problem solved! My fault...

I want to get the webserver response by:
Debug "Webserver response:" + CkHttpResponse::ckBodyStr(task)

But it has to be:
Debug "Webserver response:" + CkHttpResponse::ckBodyStr(req)

Just needed 5 hours.

:-)

Andrew Room


Answer

One more info: The "task" doesnt end successfully (CkTask::ckGetResultBool(task) = 0).

CkTask::ckStatusInt(task) = 7 -> Task finished

Here is the ckLastErrorText:

    ChilkatLog:
    SynchronousRequest:
    DllDate: Nov  2 2015
    ChilkatVersion: 9.5.0.54
    UnlockPrefix: Anything for 30-day trial
    Username: ZOTACWIN80:andreas
    Architecture: Little Endian; 32-bit
    Language: Visual C++ 9.0 (32-bit)
    VerboseLogging: 0
    domain: testpage.com
    port: 80
    ssl: 0
    httpRequest:
      httpVersion: 1.1
      verb: POST
      path: /client/postfile.php
      contentType: multipart/form-data
      charset: windows-1252
      sendCharset: 0
      mimeHeader: Expect: 100-continue
      requestParams:
        requestItem:
          name: fileitem
          fileOnDisk: s:\test2.dll
          numValueBytes: 7618560
        --requestItem
      --requestParams
    --httpRequest
    readTimeout: 20
    connectTimeout: 30
    approxRequestSize: 7618685
    fullRequest:
      a_synchronousRequest:
        generateRequest:
          httpRequestGenStartLine:
            genStartLine:
              startLine: POST /client/postfile.php HTTP/1.1
            --genStartLine
          --httpRequestGenStartLine
          addCookies:
            Not auto-adding cookies.
            sendCookies: 1
            cookieDir: 
          --addCookies
          genMultipartFormData:
            requestParam:
              name: fileitem
              filename: s:\test2.dll
            --requestParam
          --genMultipartFormData
        --generateRequest
        fullHttpRequest:
          domain: testdomain.com
          port: 80
          ssl: 0
          openHttpConnection:
            Opening connection directly to HTTP server.
            httpHostname: testdomain.com
            httpPort: 80
            ssl: 0
            HTTP connection succeeded.
          --openHttpConnection
          connectTime: Elapsed time: 3058 millisec
          sendRequestHeader:
            sendHeaderElapsedMs: 78
          --sendRequestHeader
          expect100Continue:
            statusCode: 100
            statusText: Continue
          --expect100Continue
          sendRequestBody:
            genMultipartFormData:
              requestParam:
                name: fileitem
                filename: s:\test2.dll
              --requestParam
            --genMultipartFormData
            sendBodyElapsedMs: 16021
          --sendRequestBody
          statusCode: 200
          statusText: OK
          readResponseBody:
            contentLength: 10
          --readResponseBody
        --fullHttpRequest
        success: 1
      --a_synchronousRequest
      success: 1
    --fullRequest
    totalTime: Elapsed time: 19735 millisec
    Success.
  --SynchronousRequest
--ChilkatLog

As you can see, "chilkat" gets the expected response back in the error-log: readResponseBody: contentLength: 10

But I cant get the content of the "readResponseBody".

Hope, this helps.

Regards

Andrew Room