Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent panic on empty meta with 40/50 response codes #73

Merged
merged 1 commit into from
Aug 22, 2020

Conversation

a-h
Copy link
Contributor

@a-h a-h commented Aug 22, 2020

In the case that no meta information is provided when a 40/50 response is returned, amfora currently panics when trying to title case the text and add punctuation. The Gemini "spec" doesn't require meta to be populated, so this case may need to be handled.

The contents of <META> may provide additional information on the failure, and should be displayed to human users.

@makew0rld
Copy link
Owner

Thanks! Merged.

I should be looking at my string indices more carefully, and what assumptions they have, it seems. Also, could you provide an example of a server that does this, for testing?

@makew0rld makew0rld merged commit a31e270 into makew0rld:master Aug 22, 2020
makew0rld added a commit that referenced this pull request Aug 22, 2020
@a-h
Copy link
Contributor Author

a-h commented Aug 22, 2020

My server does this (https://github.com/a-h/gemini) for 51 responses. I couldn't think of anything I wanted to say more than the 51 status already says "not found", maybe I should be more inventive. 😁

I haven't got one a server on the public Internet yet for super-easy testing, but if you use Docker:

# Create a server certificate.
openssl ecparam -genkey -name secp384r1 -out server.key
openssl req -new -x509 -sha256 -key server.key -out server.crt -days 3650
# Make a Gemini file.
mkdir content
echo "# Hello, World!" > content/index.gemini
# Run the container.
docker pull adrianhesketh/gemini:latest
docker run -v `pwd`:/certs -e PORT=1965 -e DOMAIN=localhost -v `pwd`/content:/content -p 1965:1965 adrianhesketh/gemini:latest

You should then be able to get a 51 return value with no meta information by accessing gemini://localhost/not_found

@makew0rld
Copy link
Owner

Returning just the name of the status code as a META is probably a good practice, it's what the other servers do. But I should definitely still handle this, so thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants