diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-07-28 09:00:05 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2020-07-28 09:00:05 +0300 |
commit | 0700048de99c4a00094d594dcf321637514f3a6a (patch) | |
tree | 7752bab03bc7bed5c20346116772e46e7f70fce0 /src/gmrequest.c | |
parent | 96201f4fab0ac0d97211184d2cf93b1999f8a8b8 (diff) |
Plaintext documents; unsupported MIME type error
Diffstat (limited to 'src/gmrequest.c')
-rw-r--r-- | src/gmrequest.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/gmrequest.c b/src/gmrequest.c index e05679bd..38702edb 100644 --- a/src/gmrequest.c +++ b/src/gmrequest.c | |||
@@ -182,8 +182,17 @@ void submit_GmRequest(iGmRequest *d) { | |||
182 | iFile * f = new_File(path); | 182 | iFile * f = new_File(path); |
183 | if (open_File(f, readOnly_FileMode)) { | 183 | if (open_File(f, readOnly_FileMode)) { |
184 | /* TODO: Check supported file types: images, audio */ | 184 | /* TODO: Check supported file types: images, audio */ |
185 | /* TODO: Detect text files based on contents? E.g., is the content valid UTF-8. */ | ||
185 | d->code = success_GmStatusCode; | 186 | d->code = success_GmStatusCode; |
186 | setCStr_String(&d->header, "text/gemini; charset=utf-8"); | 187 | if (endsWithCase_String(path, ".gmi")) { |
188 | setCStr_String(&d->header, "text/gemini; charset=utf-8"); | ||
189 | } | ||
190 | else if (endsWithCase_String(path, ".txt")) { | ||
191 | setCStr_String(&d->header, "text/plain"); | ||
192 | } | ||
193 | else { | ||
194 | setCStr_String(&d->header, "application/octet-stream"); | ||
195 | } | ||
187 | set_Block(&d->body, collect_Block(readAll_File(f))); | 196 | set_Block(&d->body, collect_Block(readAll_File(f))); |
188 | iNotifyAudience(d, updated, GmRequestUpdated); | 197 | iNotifyAudience(d, updated, GmRequestUpdated); |
189 | } | 198 | } |