All Projects → isemenkov → libpascurl

isemenkov / libpascurl

Licence: GPL-3.0 license
libPasCURL is delphi and object pascal wrapper around cURL library. Library for transferring data with URL syntax, supporting HTTP, HTTPS, FTP, FTPS, GOPHER, TFTP, SCP, SFTP, SMB, TELNET, DICT, LDAP, LDAPS, FILE, IMAP, SMTP, POP3, RTSP and RTMP.

Programming Languages

pascal
1382 projects

Projects that are alternatives of or similar to libpascurl

libpassqlite
libPasSQLite is delphi and object pascal bindings and wrapper around SQLite library. SQLite is library that implements a small, fast, self-contained, high-reliability, full-featured, SQL database engine.
Stars: ✭ 18 (-68.97%)
Mutual labels:  freepascal, fpc, delphi10, pascal-bindings
WebView4Delphi
WebView4Delphi is an open source project created by Salvador Díaz Fau to embed Chromium-based browsers in applications made with Delphi or Lazarus/FPC for Windows.
Stars: ✭ 157 (+170.69%)
Mutual labels:  freepascal, fpc
JPLib
A small library of Pascal units needed to compile my projects published on GitHub.
Stars: ✭ 41 (-29.31%)
Mutual labels:  freepascal, fpc
PospoliteView
Pospolite View aims to be a simple HTML viewer engine fully made in Free Pascal.
Stars: ✭ 29 (-50%)
Mutual labels:  freepascal, fpc
bcrypt
BCrypt is a password hashing function
Stars: ✭ 138 (+137.93%)
Mutual labels:  freepascal, fpc
TLightFileStream
Implements a lightweight, high-performance, non-allocating advanced-record-based wrapper around the SysUtils file handling routines as an alternative to Classes.TFileStream.
Stars: ✭ 21 (-63.79%)
Mutual labels:  freepascal, fpc
Goz
A fantastic HTTP request libarary used in Golang.
Stars: ✭ 187 (+222.41%)
Mutual labels:  curl
Goploader
Easy file sharing with server-side encryption, curl/httpie/wget compliant
Stars: ✭ 205 (+253.45%)
Mutual labels:  curl
Php Whois
PHP WHOIS provides parsed and raw whois lookup of domains and ASN routes. PHP 5.4+ and 7+ compatible
Stars: ✭ 179 (+208.62%)
Mutual labels:  curl
J2team Community
Join our group to see more
Stars: ✭ 172 (+196.55%)
Mutual labels:  curl
Websocat
Command-line client for WebSockets, like netcat (or curl) for ws:// with advanced socat-like functions
Stars: ✭ 3,477 (+5894.83%)
Mutual labels:  curl
Parrot.live
🐦 Bringing animated parrots to terminals everywhere
Stars: ✭ 2,642 (+4455.17%)
Mutual labels:  curl
Googliser
a fast BASH multiple-image downloader
Stars: ✭ 202 (+248.28%)
Mutual labels:  curl
Github.vim
Another github v3 api implemented in vim script
Stars: ✭ 187 (+222.41%)
Mutual labels:  curl
Human curl
Simple Human wrapper for cURL library
Stars: ✭ 206 (+255.17%)
Mutual labels:  curl
Curl Trace Parser
Parser for output from Curl --trace option
Stars: ✭ 183 (+215.52%)
Mutual labels:  curl
Wttr.in
⛅ The right way to check the weather
Stars: ✭ 16,345 (+28081.03%)
Mutual labels:  curl
Zebra curl
A high performance cURL PHP library for running of multiple requests at once, asynchronously
Stars: ✭ 172 (+196.55%)
Mutual labels:  curl
Lua Curlv3
Lua binding to libcurl
Stars: ✭ 197 (+239.66%)
Mutual labels:  curl
Notica
Send browser notifications from your terminal. No installation. No registration.
Stars: ✭ 215 (+270.69%)
Mutual labels:  curl

libPasCURL

It is delphi and object pascal bindings and wrapper around cURL library. libcurl is the library is using for transferring data specified with URL syntax, supporting HTTP, HTTPS, FTP, FTPS, GOPHER, TFTP, SCP, SFTP, SMB, TELNET, DICT, LDAP, LDAPS, FILE, IMAP, SMTP, POP3, RTSP and RTMP.

Table of contents

Requirements

Library is tested for

  • Embarcadero (R) Delphi 10.3 on Windows 7 Service Pack 1 (Version 6.1, Build 7601, 64-bit Edition)
  • FreePascal Compiler (3.2.0) and Lazarus IDE (2.0.10) on Ubuntu Linux 5.8.0-33-generic x86_64
  • Lazarus 2.2RC2 and the latest curl from brew package manager on MacOS (by Björn Lindh)

Installation

Get the sources and add the source directory to the project search path. For FPC add the source directory to the fpc.cfg file.

Usage

Clone the repository git clone https://github.com/isemenkov/libpascurl.

Add the unit you want to use to the uses clause.

Examples

  1. RemoteConnectCStyle simple example for use cURL wrapper in C-Style to connect to remote host.
  2. RemoteConnect example how to use curl.http.session.TSession and curl.http.response.TResponse classes to connect to remote host.

Bindings

libpascurl.pas file contains the cURL translated headers to use this library in pascal programs. You can find C API documentation at cURL website.

Usage example

  uses
    libpascurl;

  var
    handle : CURL;
    effectiveUrl, contentType, ip : PChar;
    responseCode, headerSize : Longint;
    contentLength, totalTime : Longword;
    buffer : TStringStream;

  function WriteFunctionCallback (ptr : PChar; size : LongWord;
    nmemb : LongWord; data : Pointer)
  begin
    buffer.WriteString(string(ptr)); 
  end;

  begin
    curl_global_init(CURL_GLOBAL_ALL);
    curl_easy_setopt(handle, CURLOPT_URL, PChar('https://example.dev');
    curl_easy_setopt(handle, CURLOPT_WRITEFUNCTION, @WriteFunctionCallback);
    buffer := TStringStream.Create('');

    if curl_easy_perform = CURLE_OK then
    begin
      New(effectiveUrl);
      New(contentType);
      New(ip);
  
      curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, @effectiveUrl);
      curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, @responseCode);
      curl_easy_getinfo(handle, CURLINFO_HEADER_SIZE, @headerSize);
      curl_easy_getinfo(handle, CURLINFO_CONTENT_TYPE, @contentType);
      curl_easy_getinfo(handle, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, @contentLength);
      curl_easy_getinfo(handle, CURLINFO_LOCAL_IP, @ip);
      curl_easy_getinfo(handle, CURLINFO_TOTAL_TIME_T, @totalTime);

      writeln('URL: ':20,                 effectiveUrl);
      writeln('Response code: ':20,       responseCode);
      writeln('Header size, kB: ':20,     FormatFloat('0.00', headerSize / 1024));
      writeln('Content type: ',           contentType);
      writeln('Content length, kB: ':20,  FormatFloat('0.00', contentLength / 1024));
      writeln('IP: ':20,                  ip);
      writeln('Total time, ms: ':20,      totalTime);
      writeln('==== Content ====');
      writeln(buffer.DataString);
    end;

    curl_global_cleanup; 

  end;

Object wrapper

Base functionality

The library contains a set of classes for creating high-level wrappers around the supported protocols. The source/curl/ folder contains base components that implements specific functionality.

Class Description
TCURLEasy It is base class that initialize CURL library and provides error handling functionality.
TSession It is parent class for sessions of all supported protocols. It provides a TMemoryBuffer for stored downloading/uploading data.
TResponse It is parent class for server response data.
TPropertyModule It is base class for all sessions and responses additional functionality modules.

Property modules

Session modules
Module class Description
TModuleDNS Class provide properties to setup libCurl DNS options.
TModuleRequest Class provide properties to setup request properties and callbacks.
TModuleHeader Class provide properties to setup headers. Can be used only with HTTP-like protocols - HTTP(S), FTP(S), POP3(S), IMAP, SMTP.
TModuleOptions Class provide properties to setup different libCurl internal options.
TModuleProtocols Class provide properties to setup libCurl protocol options.
TModuleSocket Class provide properties to socket setup.
TModuleTCP Class provide properties to setup TCP protocol options.
TModuleWriter Class provide properties to setup download callback function.
TModuleReader Class provide properties to setup upload callback function.
TModuleAuth Class provide properties to setup auth options.
TModuleTLSAuth Class provide properties to setup TLS auth authentication options.
TModuleProxy Class provide properties to setup proxy options.
TModuleSock5 Class provide properties to setup sock5 proxy options.
Response modules
Module class Description
TModuleContent Class provide properties to get content data buffer.
TModuleHeader Class provide properties to response headers. Can be used only with HTTP-like protocols - HTTP(S), FTP(S), POP3(S), IMAP, SMTP.
TModuleRedirect Class provide information about request redirects.
TModuleSpeed Class provide speed download/upload information.
TModuleTimeout Class provide timeouts information.
TModuleInfo Class provide session information.

HTTP

THTTPSession and THTTPResponse classes implements wrapper about HTTP(S) protocol. This classes extends the functionality of base classes and provided new one that is specific only to this protocol.

This wrapper used or extends the next main modules:

Session modules Response modules
✔️ TModuleDNS ✔️ TModuleContent
✔️ TModuleHeader ✔️ TModuleHeader
✔️ TModuleOptions ✔️ TModuleRedirect
✔️ TModuleProtocols ✔️ TModuleSpeed
✔️ TModuleSocket ✔️ TModuleTimeout
✔️ TModuleTCP ✔️ TModuleInfo
✔️ TModuleWriter
✔️ TModuleReader
✔️ TModuleRequest
✔️ TModuleAuth
✔️ TModuleTLSAuth
✔️ TModuleProxy
✔️ TModuleSock5
Session modules
Module class Description
TModuleRedirect Class provide properties to setup http(s) redirect options.
TModuleHTTP2 Class provide properties to setup HTTP/2 protocol options.
TModuleTimeout Class provide properties to setup http(s) protocol timeouts options.
Response modules
Module class Description
TModuleCookie Class provide cookies data.

Usage example

uses 
  curl.http.session, curl.http.response;
  
var
  Session : THTTP.TSession;
  Response : THHTP.TResponse;

begin
  Session.Url := 'https://github.com/isemenkov';
  Session.Redirect.FollowRedirect := True;
  
  Response := Session.Get;
  
  writeln('Url', Response.Request.Url);
  writeln('Response code', Response.Header.ResponseCode);
  writeln('Content-type', Response.Content.ContentType);
  writeln('Content-size', Response.Content.ContentSize);
  writeln('Content', Response.Content.ToString);
end;
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].