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
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.1.tar.gz
(4.8 kB
view details)
Built Distribution
File details
Details for the file gemcall-0.9.1.tar.gz
.
File metadata
- Download URL: gemcall-0.9.1.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40e5c6d097040cc1f365b349c8594fbf3569e49d10899f939275f047a4f3acf8 |
|
MD5 | 7a73673e69f6370940df70b606da255a |
|
BLAKE2b-256 | 67014265ed97d3eb72867700c377ac0c673280e62ffb3058ae66f141c32b05e6 |
File details
Details for the file gemcall-0.9.1-py3-none-any.whl
.
File metadata
- Download URL: gemcall-0.9.1-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6177b537de3a6fb371d32fe9dde0aa05e0c143e6b65c613538ffd06e3b87ba41 |
|
MD5 | 565ce40f33d2c92be1a3426165f67411 |
|
BLAKE2b-256 | 508c35d444e9318b582dacac8a6d4b0b358a4f91bbe28ddee14f758215496b03 |