Git Product home page Git Product logo

curl4delphi's Introduction

About curl4delphi

curl4delphi is a simple Delphi XE2+ binding for libcURL.

© 2015–2017 Mikhail Merkuryev

My initial version supports “easy” interface only.

Note from developer

Version 0.3 “Tokyo” is out! It is much easier than 0.2.

Check it now, though you can face some incompatibilities with older versions. But I think they are easy to overcome, nothing was changed radically.

Quick start

  1. Add files Curl.Lib, Curl.Easy, Curl.Interfaces to your project.
  2. Write such a piece of code.
var
  curl : ICurl;

curl := CurlGet;
curl.SetUrl('http://example.com')
    .SetProxyFromIe
    .SetUserAgent(ChromeUserAgent)
    .SwitchRecvToString
    .Perform;
Writeln(curl.ResponseBody);

[To use streams for receiving, check EasyHttp\StreamedDl].

Examples

Misc\Version

Shows version

RawHttp\Readme

Basic HTTP GET, same as written above.

RawHttp\Simple, EasyHttp\Simple

Redirection, basic HTTP GET, GetInfo

RawHttp\Https, EasyHttp\Https

Redirection, basic HTTPS support, CA files, Unicode in file names.

Warning: download a CA file such as cacert.pem.

EasyHttp\StreamedDl

Downloading to Delphi TStream’s.

EasyHttp\FileDownloader

A GUI file downloader. This example is rather complex because of multithreading and Content-Disposition. We do as most browsers do: request headers, then start writing to temporary file and simultaneously ask where to save it on HDD.

Inter-thread communication, transfer function, quick-and-dirty header parsing.

RawHttp\AplusB_Post, EasyHttp\AplusB_Post

A simple form demo. Please copy php_curl directory to a PHP-capable web server.

Forms (one field is set in a simple way, the other in more complex one).

EasyHttp\PhotoInfo

File uploading: disk file (2 ways), memory buffer, stream.

ICurl cloning demo (not particularly good, it is more an illustration that Clone works).

Please copy php_curl directory to a PHP-capable web server.

EasyHttp\AplusB_Get

Using ICurlGetBuilder to build a GET URL. Please copy php_curl directory to a PHP-capable web server.

License

MIT for library, public domain for examples.

curl4delphi's People

Contributors

mercury13 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

curl4delphi's Issues

Mimetype issues

Hi,
I have been using your library happily to use curl with delphi.
I ran into a few issues when using SMTP and attachments.

  1. Function curl_mime_type. Your function requires a HCurlMime argument, but the curl function seems to need a HCurlMimeType argument.
  2. For curl_easy_setopt I could not use a TCurlMimeOption. (CURLOPT_MIMEPOST). I needed to add an overloaded version of the function curl_easy_setopt.

Running a diff on your latest source of Curl.Lib.pas and my adjusted version I get this:

1760c1760
< function curl_mime_type(part : HCurlMime; mimetype : PAnsiChar) : TCurlCode;
---
> function curl_mime_type(part : HCurlMimePart; mimetype : PAnsiChar) : TCurlCode;
2616a2616,2620
> function curl_easy_setopt(
>         curl : HCurl;
> 		option : TCurlMimeOption;
> 		data : HCurlMime) : TCurlCode;  overload; inline;
> 
3062a3067,3074
> function curl_easy_setopt(
>         curl : HCurl;
> 		option : TCurlMimeOption;
> 		data : HCurlMime) : TCurlCode;
> begin
>   Result := curl_easy_setopt_initial(curl, option, NativeUInt(data));
>   end;
> 

I wanted to let you know, it seems a good improvement to me to include this into your original.
Greetings, JP.

Mapping to curl equivalent options

Hello,
Can you help me about following command

curl -vs -H "Accept-Language: bg" -H "Accept: application/json" --user a@b:12345 https://app.prolet.org/steps-beta/clients/generic/import.do -X POST -d "source_post_code=1000" -d "target_post_code=6000" -d "weight=1" -d "paidOnDelivery=true" -d "printFormat=nil" -d "include_price=true" -o d:\l2.pdf

as post me some code of delphi for this parameters
-d
-o

Thanks in advance.
Nikolay Neykov

Add a json post request example

  curl := CurlGet;
  curl.SetUrl('https://empacser.now.sh/api/sync_proxy')
    .SetCustomHeaders(
      CurlGetSlist
        .AddRaw('Content-type: application/json')
        .AddRaw('Accept: */*')
    )
    .SetProxyFromIe
    .SetOpt(CURLOPT_POST, true)
    .SetOpt(CURLOPT_POSTFIELDS, TEncoding.UTF8.GetBytes('{"xyz": 10}'))
    .SetCaFile('curl-ca-bundle.crt')
    .SetUserAgent(ChromeUserAgent)
    .SwitchRecvToString
    .Perform;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.