Git Product home page Git Product logo

fortran-curl's Introduction

fortran-curl

A collection of ISO C binding interfaces to libcurl โ‰ฅ 8.7 for Fortran 2008. The library has been tested with GNU Fortran 13 and Intel oneAPI 2024. See COVERAGE for an overview of bound procedures.

For a user-friendly, high-level HTTP library based on these bindings, see http-client.

Build Instructions

Install libcurl with development headers. On FreeBSD, run:

# pkg install ftp/curl

On Debian, instead:

# apt-get install libcurl4 libcurl4-openssl-dev

Clone the repository, then run make to build and install the interfaces to /opt:

$ git clone --depth 1 https://github.com/interkosmos/fortran-curl
$ cd fortran-curl/
$ make
$ make install PREFIX=/opt

You can override the default compilers by passing the CC and FC arguments, for example:

$ make CC=icx FC=ifx

On Linux, you may have to change the prefix to /usr:

$ make PREFIX=/usr

Link your Fortran application against /opt/lib/libfortran-curl.a -lcurl.

Examples

Examples are provided in directory examples/:

  • dict queries a DICT server on TCP port 2628.
  • download fetches a remote file.
  • getinfo prints request-related information to console.
  • gopher prints the contents of a remote Gopher map file.
  • http makes an HTTP GET request.
  • imap examines the INBOX of an IMAP mailbox (SSL).
  • mqtt posts a message to an MQTT topic.
  • multi makes multiple HTTP requests at once.
  • post makes an HTTP POST request.
  • smtp sends an e-mail via SMTP (SSL).
  • url demonstrates the URL API.
  • version outputs cURL version information.

Build an example with:

$ make <name>

Build all by running make examples.

Fortran Package Manager

This project supports the Fortran Package Manager (FPM). To build the project with FPM, run:

$ fpm build --profile release

The example programs are available with the fpm run --example command.

You can add fortran-curl to your fpm.toml with:

[dependencies]
fortran-curl = { git = "https://github.com/interkosmos/fortran-curl.git" }

Contribute

For smaller changes:

  1. Fork this repository from GitHub.
  2. Create a branch off master.
  3. Commit your changes.
  4. Send a pull request.

For larger changes:

  1. Join the Discourse Group.
  2. Discuss your proposal on the Group.
  3. When consensus is reached, implement it as described above.

Licence

ISC

fortran-curl's People

Contributors

14ngiestas avatar awvwgk avatar interkosmos avatar perazz avatar rajkumardongre 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

Watchers

 avatar  avatar  avatar  avatar

fortran-curl's Issues

Missing implementation of libcurl MIME interfaces in fortran-curl

Hi @interkosmos ,I noticed that the fortran-curl library does not currently implement the ISO C binding interfaces for libcurl's MIME feature. This means that users of fortran-curl are unable to send multipart form data.

Could you please consider adding support for these interfaces so that users can take advantage of this important feature? It would be great to have this functionality available in future releases of fortran-curl.

Thank you for your attention to this matter.

Runtime problem when using Apple Silicon

Came to http-client (another project) from: https://twitter.com/kelseyhightower/status/1696196971277775348

Installed fpm with brew from homebrew-fortran.

% brew install fpm
==> Fetching dependencies for fortran-lang/fortran/fpm: ca-certificates
==> Fetching ca-certificates
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/manifests/2023-08-22
################################################################################################################################################### 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/blobs/sha256:a331e92e7a759571296581f029e5cc2ec7cee70cd92dc0b5f8eb76095f94a21a
################################################################################################################################################### 100.0%
==> Fetching fortran-lang/fortran/fpm
==> Downloading https://github.com/fortran-lang/fpm/releases/download/v0.9.0/fpm-0.9.0.zip
==> Downloading from https://objects.githubusercontent.com/github-production-release-asset-2e65be/233763778/b18842ea-8633-4f96-bf20-fe2e3190adc4?X-Amz-Alg
################################################################################################################################################### 100.0%
==> Installing fpm from fortran-lang/fortran
==> Installing dependencies for fortran-lang/fortran/fpm: ca-certificates
==> Installing fortran-lang/fortran/fpm dependency: ca-certificates
==> Pouring ca-certificates--2023-08-22.arm64_ventura.bottle.tar.gz
==> Regenerating CA certificate bundle from keychain, this may take a while...
๐Ÿบ  /opt/homebrew/Cellar/ca-certificates/2023-08-22: 3 files, 221.7KB
==> Installing fortran-lang/fortran/fpm
==> Using Homebrew-provided Fortran compiler
This may be changed by setting the FC environment variable.
==> ./install.sh --prefix=/opt/homebrew/Cellar/fpm/0.9.0
๐Ÿบ  /opt/homebrew/Cellar/fpm/0.9.0: 6 files, 1.5MB, built in 1 minute 11 seconds

Then noticing that the http-client example code gives a runtime failure:

 Error message:URL using bad/illegal format or missing URL

Figured that internally it uses this project, fortran-curl.

Maybe you have a clue where to look, since everything compiles just fine. Not sure if Apple Silicon is even the thing causing the bug.

Running all your example programs:

for file in build/gfortran_E167FD2A985B468F/example/*; do [[ -x "$file" ]] && echo "Running $file" && ./"$file"; done

Running build/gfortran_E167FD2A985B468F/example/dict
Error: curl_easy_perform() failed
Running build/gfortran_E167FD2A985B468F/example/download
Saving https://netlib.org/fftpack/test.f to file data.txt ...
Error: curl_easy_perform() failed
Running build/gfortran_E167FD2A985B468F/example/getinfo
Sending request ...
Error: URL using bad/illegal format or missing URL
Running build/gfortran_E167FD2A985B468F/example/gopher
STOP Error: curl_easy_perform() failed
Running build/gfortran_E167FD2A985B468F/example/http
STOP Error: curl_easy_perform() failed
Running build/gfortran_E167FD2A985B468F/example/imap
* URL rejected: Malformed input to a URL function
* Closing connection -1
Error: curl_easy_perform() failed
Running build/gfortran_E167FD2A985B468F/example/post
* URL rejected: Malformed input to a URL function
* Closing connection -1
STOP Error: curl_easy_perform() failed
Running build/gfortran_E167FD2A985B468F/example/smtp
* URL rejected: Malformed input to a URL function
* Closing connection -1
Error: curl_easy_perform() failed
Running build/gfortran_E167FD2A985B468F/example/version
Version: libcurl/8.1.2 SecureTransport (LibreSSL/3.3.6) zlib/1.2.11 nghttp2/1.51.0

Host: x86_64-apple-darwin22.0
cURL: 8.1.2
SSL:  SecureTransport (LibreSSL/3.3.6)

Escaped:   escaped%20string%20%26
Unescaped: escaped string &

Though above it says x86_64, it's actually ARM64.

% file build/gfortran_E167FD2A985B468F/example/*
build/gfortran_E167FD2A985B468F/example/dict:         Mach-O 64-bit executable arm64
build/gfortran_E167FD2A985B468F/example/dict.log:     empty
build/gfortran_E167FD2A985B468F/example/download:     Mach-O 64-bit executable arm64
build/gfortran_E167FD2A985B468F/example/download.log: empty
build/gfortran_E167FD2A985B468F/example/getinfo:      Mach-O 64-bit executable arm64
build/gfortran_E167FD2A985B468F/example/getinfo.log:  empty
build/gfortran_E167FD2A985B468F/example/gopher:       Mach-O 64-bit executable arm64
build/gfortran_E167FD2A985B468F/example/gopher.log:   empty
build/gfortran_E167FD2A985B468F/example/http:         Mach-O 64-bit executable arm64
build/gfortran_E167FD2A985B468F/example/http.log:     empty
build/gfortran_E167FD2A985B468F/example/imap:         Mach-O 64-bit executable arm64
build/gfortran_E167FD2A985B468F/example/imap.log:     empty
build/gfortran_E167FD2A985B468F/example/post:         Mach-O 64-bit executable arm64
build/gfortran_E167FD2A985B468F/example/post.log:     empty
build/gfortran_E167FD2A985B468F/example/smtp:         Mach-O 64-bit executable arm64
build/gfortran_E167FD2A985B468F/example/smtp.log:     empty
build/gfortran_E167FD2A985B468F/example/version:      Mach-O 64-bit executable arm64
build/gfortran_E167FD2A985B468F/example/version.log:  empty

Apart from the http example outputting some garbage (probably an uninitialised string) under the 0.1.0 and 0.1.1 tag, all of the earlier versions fail in a fairly similar way. So it's not an introduced bug (not a regression).

Version number?

I haven't found a version for this project yet. While the important version number might be the libcurl version, the version of the Fortran interface is relevant for consumers of this library as well.

Is there a plan to add a version number and/or create versioned releases for this project?

Error: Type mismatch in argument 'parameter' at (1); passed INTEGER(8) to INTEGER(4)

Got this error trying to build fortran-curl:

src/curl.f90:748:13:

  748 |         rc = curl_easy_setopt_c_long(curl, option, parameter)
      |             1
Error: Type mismatch in argument 'parameter' at (1); passed INTEGER(8) to INTEGER(4)
compilation terminated due to -fmax-errors=1.
make: *** [libfortran-curl.a] Error 1

macOS 10.6.8, ppc32, gfortran 12.2.0

Errro while building the project

During the execution of fpm build, it appears that the library is not being built correctly. The following error is encountered:

build/dependencies/fortran-curl/src/curl.f90:1135:57:

 1135 |         call c_f_str_ptr(ptr, unescaped, int(o, kind=i8))
      |                                                         1
Error: More actual than formal arguments in procedure call at (1)
<ERROR> Compilation failed for object " build_dependencies_fortran-curl_src_curl.f90.o "
<ERROR> stopping due to failed compilation
STOP 1

Retrieve Response Cookies

Hello @interkosmos,
How can I receive response cookies in an HTTP request? I know that one way to do this is to search for cookies in the response headers, specifically in the Set-Cookie header.

I have found that in curl, we can use the curl_easy_getinfo function with the CURLINFO_COOKIELIST option to retrieve cookie information. However, I am encountering an error while using this approach. Can you please provide an example demonstrating how to receive cookies using the CURLINFO_COOKIELIST option? Alternatively, if you know of any better approach, please let me know.

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.