Code Review
/
src
/
app-framework-binder.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
afb-config: Add traceses for tracing sessions
[src/app-framework-binder.git]
/
src
/
afb-hreq.c
diff --git
a/src/afb-hreq.c
b/src/afb-hreq.c
index
a8aae40
..
3a47766
100644
(file)
--- a/
src/afb-hreq.c
+++ b/
src/afb-hreq.c
@@
-271,34
+271,38
@@
static const char *mimetype_fd_name(int fd, const char *filename)
const char *extension = strrchr(filename, '.');
if (extension) {
static const char *const known[][2] = {
const char *extension = strrchr(filename, '.');
if (extension) {
static const char *const known[][2] = {
- { ".js", "text/javascript" },
- { ".json", "application/json" },
- { ".html", "text/html" },
+ /* keep it sorted for dichotomic search */
{ ".css", "text/css" },
{ ".css", "text/css" },
+ { ".gif", "image/gif" },
+ { ".html", "text/html" },
+ { ".htm", "text/html" },
{ ".ico", "image/x-icon"},
{ ".ico", "image/x-icon"},
- /* TODO: CHECK ME { ".ico", "image/vnd.microsoft.icon" }, */
+ { ".jpeg", "image/jpeg" },
{ ".jpg", "image/jpeg" },
{ ".jpg", "image/jpeg" },
+ { ".js", "text/javascript" },
+ { ".json", "application/json" },
+ { ".mp3", "audio/mpeg" },
{ ".png", "image/png" },
{ ".svg", "image/svg+xml" },
{ ".ttf", "application/x-font-ttf"},
{ ".png", "image/png" },
{ ".svg", "image/svg+xml" },
{ ".ttf", "application/x-font-ttf"},
- { ".htm", "text/html" },
- { ".xml", "application/xml" },
{ ".txt", "text/plain" },
{ ".wav", "audio/x-wav" },
{ ".txt", "text/plain" },
{ ".wav", "audio/x-wav" },
- { ".xhtml", "application/xhtml+xml" },
{ ".xht", "application/xhtml+xml" },
{ ".xht", "application/xhtml+xml" },
- { ".gif", "image/gif" },
- { ".png", "image/png" },
- { ".mp3", "audio/mpeg" },
- { NULL, NULL }
+ { ".xhtml", "application/xhtml+xml" },
+ { ".xml", "application/xml" }
};
};
- int i = 0;
- while (known[i][0]) {
- if (!strcasecmp(extension, known[i][0])) {
+ int i, c, l = 0, u = sizeof known / sizeof *known;
+ while (l < u) {
+ i = (l + u) >> 1;
+ c = strcasecmp(extension, known[i][0]);
+ if (!c) {
result = known[i][1];
break;
}
result = known[i][1];
break;
}
- i++;
+ if (c < 0)
+ u = i;
+ else
+ l = i + 1;
}
}
#endif
}
}
#endif