gpt4 book ai didi

ajax - 用于 VBA 检索大型 HTTP 请求的 MSXML2 的替代方案,可以访问 readyState 3?

转载 作者:行者123 更新时间:2023-12-04 05:20:26 26 4
gpt4 key购买 nike

编辑:这个问题已经改变,因为我一直在等待答案并进行外部研究。我已经改写了标题,问题实际上是我正在寻找 MSXML2 的替代方案(即使这意味着编写套接字代码)。
问题的原始正文留在这里以供引用,以帮助将来进行类似搜索的人。

In VBA, using MSXML2 object, is there a way to get access to the streaming data while readyState = 3, as it comes in?

I am using the OnReadyStateChange method, but I don't seem to have access to responseText until readyState is 4. When readyState is 3, there doesn't seem to be any data.

Is there any way in VBA to have access to the HTTP streaming response while it is coming in? Another method I could use in MSXML2, or a better (free, distributable) object to use to make "AJAX" calls?

More information: If I try to read responseStream (or responseText), the error description is:

The data necessary to complete this operation is not yet available.

Second edit, more information: This link basically says that this is expected behavior in the INTERACTIVE (3) state:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms753800(v=vs.85).aspx



所以我肯定在寻找“还有其他选择吗?”回答。

最佳答案

这是我写的一段旧代码,用于使用 WinInet API 读取块,它不是异步的,但它在每 512 个字节后公开一个读取缓冲区(我添加了一个 Debug.Print "READ "& lngTotalBytesRead 来说明)- http://pastebin.com/6uMhkBUF

据我所知,它工作正常,但我不得不稍微取消一下。

  • 您需要删除对 App. 的调用。在 HTTPGetUAString (最初是 VB6)所以只是 HTTPGetUAString = "MyThing"或类似。
  • If (lngContentLen = 0&) Then lngContentLen = (BUFF_LEN * DUMMY_BUFF_MULTIPLIER)是剩菜;您可以删除该行。 (随后如果 lngContentLen 为零,则大小事先未知)
  • 关于ajax - 用于 VBA 检索大型 HTTP 请求的 MSXML2 的替代方案,可以访问 readyState 3?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13744301/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com