aboutsummaryrefslogtreecommitdiff
path: root/response.go
diff options
context:
space:
mode:
authorAdnan Maolood <[email protected]>2020-10-31 20:32:38 -0400
committerAdnan Maolood <[email protected]>2020-10-31 20:32:38 -0400
commita2fc1772bfae08b003dfd1174fd76d189f0120da (patch)
tree4d73cd25b4c8b93b470fefad5b6d63f99d9d6546 /response.go
parentRemove Redirect and PermanentRedirect functions (diff)
downloadgo-gemini-a2fc1772bfae08b003dfd1174fd76d189f0120da.tar.xz
go-gemini-a2fc1772bfae08b003dfd1174fd76d189f0120da.zip
Set default mimetype if META is empty
Diffstat (limited to 'response.go')
-rw-r--r--response.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/response.go b/response.go
index 4b207e5..8f24419 100644
--- a/response.go
+++ b/response.go
@@ -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