mirror of
https://tildegit.org/solderpunk/molly-brown.git
synced 2025-04-13 09:29:46 +00:00
Set missing scheme to gemini://, and return status 53 for non-Gemini schemes.
This commit is contained in:
parent
7566636c97
commit
dc92fbd228
1 changed files with 14 additions and 0 deletions
14
handler.go
14
handler.go
|
@ -41,6 +41,20 @@ func handleGeminiRequest(conn net.Conn, config Config, logEntries chan LogEntry)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.RequestURL = URL.String()
|
log.RequestURL = URL.String()
|
||||||
|
|
||||||
|
// Set implicit scheme
|
||||||
|
if URL.Scheme == "" {
|
||||||
|
URL.Scheme = "gemini"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reject non-gemini schemes
|
||||||
|
if URL.Scheme != "gemini" {
|
||||||
|
conn.Write([]byte("53 No proxying to non-Gemini content!\r\n"))
|
||||||
|
log.Status = 53
|
||||||
|
logEntries <- log
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Generic response
|
// Generic response
|
||||||
conn.Write([]byte("20 text/gemini\r\n"))
|
conn.Write([]byte("20 text/gemini\r\n"))
|
||||||
body := fmt.Sprintf("Molly at %s says \"Hi!\" from %s.\n", URL.Host, URL.Path)
|
body := fmt.Sprintf("Molly at %s says \"Hi!\" from %s.\n", URL.Host, URL.Path)
|
||||||
|
|
Loading…
Add table
Reference in a new issue