Skip to main content

A library and CLI tool for making gemini requests.

Project description

gemcall

Python module/CLI program for making network requests with the gemini protocol.

Command line usage

usage: gemcall [-h] [-c CLIENTCERT] [-k CLIENTKEY] [-u URL] [-o OUTPUTFILE]
               [-t TIMEOUT] [-q] [-n] [-s]

Python module/CLI program for making network requests with the gemini
protocol.

optional arguments:
  -h, --help            show this help message and exit
  -c CLIENTCERT, --clientcert CLIENTCERT
                        Path to client certificate. This is optional, but must
                        be used when -k/--clientkey is used.
  -k CLIENTKEY, --clientkey CLIENTKEY
                        Path to the private key file for a client certificate.
                        This is optional, but must be used when
                        -c/--clientcert is used.
  -u URL, --url URL     Fully qualified URL to fetch.
  -o OUTPUTFILE, --outputfile OUTPUTFILE
                        File to output response body to.
  -t TIMEOUT, --timeout TIMEOUT
                        Timeout of connection attempt, in seconds. Default is
                        3.
  -q, --quiet           Don't print response header.
  -n, --nobody          Only print response header.
  -s, --stdoutonly      Print everything to stdout

Installation

Packaging status

pip install git+https://notabug.org/tinyrabbit/gemcall.git#egg=gemcall
# unofficial package is uploaded on PyPI for convenience
pip install gemcall

Library Usage

import gemcall

response = gemcall.request(url)

# OR

response = gemcall.request(url, clientcert, clientkey)

while True:
    buf = response.read()
    if len(buf) > 0:
        sys.stdout.buffer.write(buf)
    else:
        break

response.discard()

The gemcall.Response object has the following values:

  • serverpubkey: the public key part of the server certificate (the ONLY relevant part in TOFU certificate validation).
  • responsecode: the response code from the server.
  • meta: the rest of the header.

The method read() should be used to get content from the response object. It takes an argument 'bufsize', which is how many bytes it will read at most. This defaults to 4096.

When you are done reading the response you should use the discard() method to close all file handles and sockets the Response object is handling.

CLI Usage

gemcall [OPTIONS]

Features

  • Supports client certificates.
  • Supports streaming.

Todo

  • Error checking >.<
  • Validation of response code and meta.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gemcall-0.9.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

gemcall-0.9-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file gemcall-0.9.tar.gz.

File metadata

  • Download URL: gemcall-0.9.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 PyPy/7.3.9

File hashes

Hashes for gemcall-0.9.tar.gz
Algorithm Hash digest
SHA256 4bdbe5db22513f2e8936641e97e89030449ac538c4c3ed2f75fc05746b23cc12
MD5 6ae25389be3848383cc9c792a80606ba
BLAKE2b-256 92396cc641263cd0ffff5081c3d809ce995eab28b761ef13203344e4317bf9a9

See more details on using hashes here.

File details

Details for the file gemcall-0.9-py3-none-any.whl.

File metadata

  • Download URL: gemcall-0.9-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 PyPy/7.3.9

File hashes

Hashes for gemcall-0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 5d77de72c7e33317aa2d8561bb8004efbd9c9c66328d2b676602308880e56eb7
MD5 396571e670f48d52e49c121a6d117d44
BLAKE2b-256 c035e0d389b40adfefe340ab4da4e98a3d238ba7d42af592c278c96b2ab62b0a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page