login about faq

I’m calling PTextAsync.

Set task = http.PTextAsync("POST", sURL, sPostData, "UTF-8", "plain/text", 0, 0)

After the task has completed, how do I get to the response object? i.e. resp.StatusCode, resp.BodyStr

asked Apr 26 at 11:55

chilkat's gravatar image

chilkat ♦♦
11.8k316358421


Each type of Chilkat object that can possibly be the return value of a synchronous method call will have a method named LoadTaskResult.

For example, when http.PText is called synchronously,it would return an HttpResponse object. When called asynchronously (i.e. http.PTextAsync) it returns a Task object. When the task completes, the task object (internally) has a reference to the returned HttpResponse object.

Chilkat could have designed the software so that an app would get the returned object via a call to the Task object. For example, something like (in pseudo-code)

response = task.GetHttpResponseObject();   // This is NOT what Chilkat does..
This would be most straightforward, but would cause internal linkage across Chilkat classes, and for various reasons it's best to keep unrelated internal code from referencing each other.

The chosen solution is a little more roundabout. To get the returned object (such as the HttpResponse object), your app creates a new instance of the object and then calls LoadTask result. For example, in VB6:

Dim response As New ChilkatHttpResponse
success = response.LoadTaskResult(task)
Now you have a response object that's been loaded with the response object returned asynchronously in the background thread.

link

answered Apr 26 at 12:08

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

edited Apr 26 at 12:08

It appears to be working, although success is 0, I expected 1. The response code: 200, bodystr is fine.

Dim response As New ChilkatHttpResponse
success = response.LoadTaskResult(task)
If (success <> 1) Then
    MsgBox "success?: " & success & " - " & http.LastErrorText
End If

Here is the log:

ChilkatLog:
  PText:
    DllDate: Mar 11 2016
    ChilkatVersion: 9.5.0.56
    UnlockPrefix: xxxxxxxxx
    Username: xxx-PC-00201:xxxxx
    Architecture: Little Endian; 32-bit
    Language: ActiveX
    VerboseLogging: 0
    binaryRequest:
      fullRequest:
        a_synchronousRequest:
          generateRequestHeader:
            httpRequestGenStartLine:
              genStartLine:
                startLine: POST /net2.0/Login/login/LoginMenu.aspx HTTP/1.1
              --genStartLine
            --httpRequestGenStartLine
            addCookies:
              Not auto-adding cookies.
              sendCookies: 1
              cookieDir: 
            --addCookies
          --generateRequestHeader
          fullHttpRequest:
            domain: xxxxxxxx
            port: 80
            ssl: 0
            openHttpConnection:
              Opening connection directly to HTTP server.
              httpHostname: xxx-pc-00201
              httpPort: 80
              ssl: 0
              HTTP connection succeeded.
            --openHttpConnection
            connectTime: Elapsed time: 0 millisec
            sendRequestHeader:
              sendHeaderElapsedMs: 16
            --sendRequestHeader
            statusCode: 200
            statusText: OK
            readResponseBody:
              contentLength: 53620
            --readResponseBody
          --fullHttpRequest
          success: 1
        --a_synchronousRequest
        success: 1
      --fullRequest
    --binaryRequest
    Success.
  --PText
--ChilkatLog

link

answered Apr 26 at 13:43

davesiracusa's gravatar image

davesiracusa
1111

edited Apr 26 at 15:25

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

Thanks! I remember this problem and thought it was fixed. I'll have a look -- maybe the error is specific to the ActiveX..

link

answered Apr 26 at 13:56

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

I fixed the problem and if you need, I can provide a pre-release. Otherwise, it will be in the next version released. A workaround would be to check the response.StatusCode property after calling LoadTaskResult. If the StatusCode equals 0, then the response was not loaded.

link

answered Apr 26 at 15:33

chilkat's gravatar image

chilkat ♦♦
11.8k316358421

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×186
×22
×8

Asked: Apr 26 at 11:55

Seen: 341 times

Last updated: Apr 26 at 15:33

powered by OSQA