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
provides developper files
[src/app-framework-binder.git]
/
src
/
afb-hreq.c
diff --git
a/src/afb-hreq.c
b/src/afb-hreq.c
index
518bc5c
..
a1c750b
100644
(file)
--- a/
src/afb-hreq.c
+++ b/
src/afb-hreq.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright
2016 IoT.bzh
+ * Copyright
(C) 2016 "IoT.bzh"
* Author: José Bollo <jose.bollo@iot.bzh>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Author: José Bollo <jose.bollo@iot.bzh>
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@
-26,14
+26,14
@@
#include <sys/stat.h>
#include <microhttpd.h>
#include <sys/stat.h>
#include <microhttpd.h>
-#include <json.h>
+#include <json
-c/json
.h>
#if defined(USE_MAGIC_MIME_TYPE)
#include <magic.h>
#endif
#include "afb-method.h"
#if defined(USE_MAGIC_MIME_TYPE)
#include <magic.h>
#endif
#include "afb-method.h"
-#include
"afb-req-itf.h"
+#include
<afb/afb-req-itf.h>
#include "afb-msg-json.h"
#include "afb-context.h"
#include "afb-hreq.h"
#include "afb-msg-json.h"
#include "afb-context.h"
#include "afb-hreq.h"
@@
-234,18
+234,15
@@
static magic_t lazy_libmagic()
done = 1;
/* MAGIC_MIME tells magic to return a mime of the file,
but you can specify different things */
done = 1;
/* MAGIC_MIME tells magic to return a mime of the file,
but you can specify different things */
- if (verbosity)
- fprintf(stderr, "Loading mimetype default magic database\n");
-
+ INFO("Loading mimetype default magic database");
result = magic_open(MAGIC_MIME_TYPE);
if (result == NULL) {
result = magic_open(MAGIC_MIME_TYPE);
if (result == NULL) {
-
fprintf(stderr,"ERROR: unable to initialize magic library\n
");
+
ERROR("unable to initialize magic library
");
}
/* Warning: should not use NULL for DB
[libmagic bug wont pass efence check] */
else if (magic_load(result, MAGIC_DB) != 0) {
}
/* Warning: should not use NULL for DB
[libmagic bug wont pass efence check] */
else if (magic_load(result, MAGIC_DB) != 0) {
- fprintf(stderr,"cannot load magic database - %s\n",
- magic_error(result));
+ ERROR("cannot load magic database: %s", magic_error(result));
magic_close(result);
result = NULL;
}
magic_close(result);
result = NULL;
}
@@
-435,8
+432,7
@@
int afb_hreq_reply_file_if_exist(struct afb_hreq *hreq, int dirfd, const char *f
if (inm && 0 == strcmp(inm, etag)) {
/* etag ok, return NOT MODIFIED */
close(fd);
if (inm && 0 == strcmp(inm, etag)) {
/* etag ok, return NOT MODIFIED */
close(fd);
- if (verbosity)
- fprintf(stderr, "Not Modified: [%s]\n", filename);
+ DEBUG("Not Modified: [%s]", filename);
response = MHD_create_response_from_buffer(0, empty_string, MHD_RESPMEM_PERSISTENT);
status = MHD_HTTP_NOT_MODIFIED;
} else {
response = MHD_create_response_from_buffer(0, empty_string, MHD_RESPMEM_PERSISTENT);
status = MHD_HTTP_NOT_MODIFIED;
} else {
@@
-475,10
+471,10
@@
int afb_hreq_reply_file(struct afb_hreq *hreq, int dirfd, const char *filename)
int afb_hreq_redirect_to(struct afb_hreq *hreq, const char *url)
{
int afb_hreq_redirect_to(struct afb_hreq *hreq, const char *url)
{
+ /* TODO: append the query part! */
afb_hreq_reply_static(hreq, MHD_HTTP_MOVED_PERMANENTLY, 0, NULL,
MHD_HTTP_HEADER_LOCATION, url, NULL);
afb_hreq_reply_static(hreq, MHD_HTTP_MOVED_PERMANENTLY, 0, NULL,
MHD_HTTP_HEADER_LOCATION, url, NULL);
- if (verbosity)
- fprintf(stderr, "redirect from [%s] to [%s]\n", hreq->url, url);
+ DEBUG("redirect from [%s] to [%s]", hreq->url, url);
return 1;
}
return 1;
}