summaryrefslogtreecommitdiff
path: root/src/gmrequest.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gmrequest.c')
-rw-r--r--src/gmrequest.c11
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 }