hurl: getting easy handle from multi:InfoRead()

Discuss about plugins that don't have a dedicated forum
Post Reply
User avatar
Amile
Posts: 4
Joined: Tue Oct 02, 2012 2:00 am

hurl: getting easy handle from multi:InfoRead()

Post by Amile »

Hello,

i'am just reading the hurl documentation and compare it with the c api docs from libcurl to gain further insights how to use the plugin.

What i still don't understand is, how do you retrieve the easy handle from the result of multi:InfoRead()

Code: Select all

msg, result, remaining = multi:InfoRead()
I can identify the resulting variables in the libcurl documentation, but where is the easy handle stored, to which the message belongs ?

Code: Select all

#include <curl/curl.h>

CURLMsg *curl_multi_info_read( CURLM *multi_handle,   int *msgs_in_queue);

 struct CURLMsg {
   CURLMSG msg;       /* what this message means */
   CURL *easy_handle; /* the handle it concerns */
   union {
     void *whatever;    /* message-specific data */
     CURLcode result;   /* return code for transfer */
   } data;
 };
User avatar
Amile
Posts: 4
Joined: Tue Oct 02, 2012 2:00 am

Re: hurl: getting easy handle from multi:InfoRead()

Post by Amile »

i read further into this topic, consulted the documentation of pycurl and even luacurl

Code: Select all

Python:
num_q, ok_list, err_list = m.info_read()
remaining, tuple of successful handles and a list of failed handles alongside
with errorcode

Lua:
e, ok, err = m:info_read(true)
handle, status and errormessage In case of failure 
To test Hollywood, i ported one luacurl example to .hws

https://github.com/Lua-cURL/Lua-cURLv3/ ... multi2.lua

Code: Select all

@REQUIRE "hurl"

Function p_WriteData(data$,did)
   WriteBytes(did, data$)
EndFunction

f1 = OpenFile(Nil,"lua.html",#MODE_WRITE)
f2 = OpenFile(Nil,"luajit.html",#MODE_WRITE)

; setup easy and url
c1 = hurl.Easy()
c1:SetOpt_URL("http://www.lua.org/")
c1:SetOpt_WriteFunction(p_WriteData,f1)
c1:SetOpt_FollowLocation(True)
c2 = hurl.Easy()
c2:SetOpt_URL("http://luajit.org/")
c2:SetOpt_WriteFunction(p_WriteData,f2)
c2:SetOpt_FollowLocation(True)
; UNSUPPORTED_PROTOCOL to force error
c3 = hurl.Easy()
c3:SetOpt_URL("****://luajit.org/")
c3:SetOpt_WriteFunction(p_WriteData)
c3:SetOpt_FollowLocation(True)
DebugPrint(c1,c2,c3)

m = hurl.multi()
m:addhandle(c1)
m:addhandle(c2)
m:addhandle(c3)
DebugPrint("start")
Local remain = 3
While remain > 0
  Local last = m:perform() ; do some work
  If last < remain         ; we have done some tasks
    While 1                ; proceed results/errors
      Local msg, result, remaining = m:InfoRead() ; get result and remove handle
      DebugPrint(msg, result, remaining)
      If remaining = 0
        Break ; no more finished tasks
      EndIf
    wend
  endif
  remain = last

  ; wait while libcurl do io select
  m:Wait(1.0)
Wend
m:RemoveHandle(c1)
m:RemoveHandle(c2)
m:RemoveHandle(c3)
c1:close()
c2:close()
c3:close()
m:close()
CloseFile(f1)
CloseFile(f2) 
The output of the three DebugPrint are

Code: Select all

> hollywood multitest.hws
LcURL Easy (0x1adc6098) LcURL Easy (0x18b7efb0) LcURL Easy (0x18b7f068)
start
1 1 0
1 0 0
1 0 0
The multi:InfoRead() in Hollywood gives indeed no handles, just returncodes with absolutly no information to which transfer the message belongs to.

So my question from the first post remains even more intact.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: hurl: getting easy handle from multi:InfoRead()

Post by airsoftsoftwair »

Yes, you're right. multi:InfoRead() currently doesn't return the easy handle at all. LuaCurl has this limitation as well but I can fix this for the next version.
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: hurl: getting easy handle from multi:InfoRead()

Post by airsoftsoftwair »

Code: Select all

- New: multi:InfoRead() returns a fourth value now; this return value will contain the easy handle
  that has previously been added to the multi handle
Post Reply