gusmobile

python gemini client library
git clone https://git.clttr.info/gusmobile.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit 701629005e0ff74e3461d4646481a35bb46bee94
parent ec5ae3143156917406d29fb174ce9534ac090910
Author: René Wagner <rwa@clttr.info>
Date:   Sun, 27 Aug 2023 15:09:41 +0200

fix Content-Type handling and add basic tests

Diffstat:
Mgusmobile/client.py | 4++--
Dtests/context.py | 6------
Atests/test_gusmobile.py | 14++++++++++++++
3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/gusmobile/client.py b/gusmobile/client.py @@ -166,7 +166,7 @@ def fetch(raw_url): mime = "text/gemini; charset=utf-8" msg = EmailMessage() msg['content-type'] = mime - mime, mime_options = msg.get_content_type(), msg['content_type'].params + mime, mime_options = msg.get_content_type(), msg['Content-Type'].params default_charset = "utf-8" charset = None if "charset" in mime_options: @@ -213,7 +213,7 @@ def _send_request(url): _debug("Connecting to: " + str(address[4])) s = socket.socket(address[0], address[1]) s.settimeout(15.0) - context = ssl.SSLContext() + context = ssl.SSLContext(protocol=ssl.PROTOCOL_TLS_CLIENT) context.check_hostname = False context.verify_mode = ssl.CERT_NONE # Impose minimum TLS version diff --git a/tests/context.py b/tests/context.py @@ -1,6 +0,0 @@ -import sys -import os - -sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) - -import gusmobile diff --git a/tests/test_gusmobile.py b/tests/test_gusmobile.py @@ -0,0 +1,14 @@ +import sys +import os +import pytest + +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) + +import gusmobile + +class TestGusMobile: + def test_gusmobile_fetch(self): + url = "gemini://heathens.club/~fluentpwn/" + + response = gusmobile.fetch(url) + assert response != ""