chubin / chubin/cheat.sh

Send HTTP 404 when a sheet doesn't exist

Open
#198 2 comments 0 reactions 1 assignee Claimed by @chubin View on GitHub
bug important
Dominant language
Python
Stars
41.7k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

I wanted to check if a few cheat sheets exist on cht.sh or not. The right way to do this would be via HTTP status codes, so I fired up a few HEAD requests. But cht.sh always returns 200 - even when sheets don't exist.

```
❯ curl --head http://cht.sh/kdialog

HTTP/1.1 200 OK
Server: nginx/1.13.12
Date: Wed, 20 May 2020 16:38:39 GMT
Content-Type: text/plain; charset=utf-8
Content-Length: 107
Connection: keep-alive
Strict-Transport-Security: max-age=63072000; includeSubdomains
X-Frame-Options: DENY
X-Content-Type-Options: nosniff

❯ curl http://cht.sh/kdialog

Unknown topic.
Do you mean one of these topics maybe?

* dig 60
* git-log 57
* killall 57
```

From the headers, it's hard to see if the cheatsheet exists on the repo or not.

`Content-Length` could be an indicator.

But I think the right thing would be to return 404 along with the message?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.