Set default mimetype if META is empty

This commit is contained in:
Adnan Maolood
2020-10-31 20:32:38 -04:00
parent 63b9b484d1
commit a2fc1772bf
2 changed files with 13 additions and 16 deletions

View File

@@ -9,7 +9,7 @@ import (
// Response is a Gemini response.
type Response struct {
// Status represents the response status.
// Status contains the response status code.
Status Status
// Meta contains more information related to the response status.
@@ -21,7 +21,7 @@ type Response struct {
// Body contains the response body for successful responses.
Body io.ReadCloser
// Request is the request that was sent to obtain this Response.
// Request is the request that was sent to obtain this response.
Request *Request
// TLS contains information about the TLS connection on which the response
@@ -68,6 +68,10 @@ func (resp *Response) read(rc io.ReadCloser) error {
if len(meta) > 1024 {
return ErrInvalidResponse
}
// Default mime type of text/gemini; charset=utf-8
if statusClass == StatusClassSuccess && meta == "" {
meta = "text/gemini; charset=utf-8"
}
resp.Meta = meta
// Read terminating newline