Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[0be611]: sighttpd-statictext-content-type.patch Maximize Restore History

Download this file

sighttpd-statictext-content-type.patch    75 lines (60 with data), 2.3 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
diff -rupN sighttpd-1.1.0/src/statictext.c sighttpd-1.1.0m2/src/statictext.c
--- sighttpd-1.1.0/src/statictext.c 2010-04-17 22:48:28.000000000 -0400
+++ sighttpd-1.1.0m2/src/statictext.c 2012-04-17 15:47:38.271879494 -0400
@@ -10,11 +10,14 @@
#include "params.h"
#include "resource.h"
+#define DEFAULT_CONTENT_TYPE "text/plain"
+
#define x_strdup(s) ((s)?strdup((s)):(NULL))
struct statictext {
char * path;
char * text;
+ char * ctype;
};
static int
@@ -35,7 +38,7 @@ statictext_head (http_request * request,
*status_line = http_status_line (HTTP_STATUS_OK);
- r = params_append (r, "Content-Type", "text/plain");
+ r = params_append (r, "Content-Type", st->ctype);
snprintf (length, 16, "%d", strlen (st->text));
*response_headers = params_append (r, "Content-Length", length);
}
@@ -60,7 +63,7 @@ statictext_delete (void * data)
}
struct resource *
-statictext_resource (char * path, char * text)
+statictext_resource (char * path, char * text, char * ctype)
{
struct statictext * st;
@@ -69,6 +72,7 @@ statictext_resource (char * path, char *
st->path = x_strdup(path);
st->text = x_strdup(text);
+ st->ctype = x_strdup(ctype);
return resource_new (statictext_check, statictext_head, statictext_body, statictext_delete, st);
}
@@ -79,14 +83,18 @@ statictext_resources (Dictionary * confi
list_t * l;
const char * path;
const char * text;
+ const char * ctype;
l = list_new();
path = dictionary_lookup (config, "Path");
text = dictionary_lookup (config, "Text");
+ ctype = dictionary_lookup (config, "Type");
+
+ if (!ctype) ctype = DEFAULT_CONTENT_TYPE;
if (path && text)
- l = list_append (l, statictext_resource (path, text));
+ l = list_append (l, statictext_resource (path, text, ctype));
return l;
}
diff -rupN sighttpd-1.1.0/src/statictext.h sighttpd-1.1.0m2/src/statictext.h
--- sighttpd-1.1.0/src/statictext.h 2010-04-06 19:59:59.000000000 -0400
+++ sighttpd-1.1.0m2/src/statictext.h 2012-04-17 15:47:57.608885989 -0400
@@ -1,5 +1,5 @@
#include "resource.h"
#include "list.h"
-struct resource * statictext_resource (char * path, char * text);
+struct resource * statictext_resource (char * path, char * text, char * ctype);
list_t * statictext_resources (Dictionary * config);