Repeated calls to RexxCurl

Help
2007-03-15
2013-04-25
  • Jon Wolfers

    Jon Wolfers - 2007-03-15

    Hi,

    Win XP Home, ooRexx 3.0.0, rexxcurl 1.4 16 Oct 2005 libcurl/7.14.0 zlib/1.2.2

    Pretty new to cURL & rexxcURL.

    I need to retrieve a URL, parse out another URL from the returned code, Get Just the Header of that url, If and only if it is not a HTTP 404 retrieve the whole of that url.

    I'm attempting to do this as three curlperforms.

    The problem I'm encountering is that Options seem to persist from curlperform to curlperform.
    So for mysecond call I set a headerfile & the nobody option

       call CurlSetOpt curl, 'NOBODY', 1
       if curlerror.intcode \= 0 then call Abort 'Error setting NOBODY option'

       call CurlSetOpt curl, 'HEADERFILE', tf
       if curlerror.intcode \= 0 then call Abort 'Error setting HEADERFILE option'

    which works fine, but then when I subsequently go to get the body I try to reset the options thus:

       call CurlSetOpt curl, 'NOBODY', 0
       if curlerror.intcode \= 0 then call Abort 'Error setting NOBODY option'

       call CurlSetOpt curl, 'OUTFILE', _File~strip
       if curlerror.intcode \= 0 then call Abort 'Error setting outfile' _file

    and I get the following error:

    cURL error: 18 - transfer closed with 175576 bytes remaining to read
    and the outfile contains the header instead of the body

    However if I don't check the header first it works fine.
    I tried doing a curlCleanup & retrieving a fresh handle, but the handle that returns is the same and doing a curlperform on it crashes the interpreter (in ntdll.dll).

    I intuit that what I need to do is cancel the headerfile option somehow but I'm not sure how.
    Can anyone advise me please.

    thanks,

    Jon

     
    • Jon Wolfers

      Jon Wolfers - 2007-03-16

      Whilst I think this is a sign of something wrong, either in Rexx\cURL, cURL, or my understanding of the above I have now found a workaround of setting

         call CurlSetOpt curl, 'FAILONERROR', 'Y'
      and checking curlError.curlCode for a 22 after the curlPerform.

      This way I don't have to set the NOBODY option and cope with the consequences.

      Many thanks to all the contributors,

      Jon

       

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks