Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use the Red cURL binding?

Tags:

curl

red

I am just getting started with Red and I need help to get the cURL binding working.

The cURL link from the main red-lang site takes you here

http://red.esperconsultancy.nl/Red-cURL/dir?ci=tip

But there is only a small example using Red/System hence I am not sure how to load the binding in Red directly.

I need to get this working on Mac, Linux and maybe Windows so I would appreciate any pointers to differences between these platforms.

like image 816
redbot Avatar asked Feb 12 '14 09:02

redbot


People also ask

What is M in cURL?

-m, --max-time <seconds> Maximum time in seconds that you allow the whole operation to take. This is useful for preventing your batch jobs from hanging for hours due to slow networks or links going down. Since 7.32.

What is cURL O?

cURL Command File Options -O will save the file in the current working directory with the same file name as remote. -o lets you specify a different file name or location.

What is cURL V?

-v (lower case letter v) means "verbose mode please" and will make curl show its request, the response headers and additional informational details about the transfer performed.


1 Answers

A few things to address:

  1. Next, there are some dependencies between bindings. I am maintaining a github clone if you don't want to use the script download.r in the Red-test files with Fossil. The cURL library explicitly depends on the C-library binding. I didn't look, but like depends on the Common binding at a lower level.

  2. Because of the lack of url! type in Red at the moment, you pass the function read-url a string! or a c-string! more specifically.

  3. With Red/System bindings used in Red, the ideal situation is to have a wrapper that abstracts the lower level code. You can see this on TryRebol with running read "http://www.google.com". Although this console build does not seem to use cURL binding for that implementation.

  4. In order to use a Red/System binding in Red, you need to use the #system-global directive. Here is a simple script that grabs the data from a website:

    Red[]
    
    #system-global [
        #include %../cURL.reds
        with curl [
            print read-url "http://www.red-lang.org"
        ]
    ]
    
like image 183
kealist Avatar answered Sep 20 '22 03:09

kealist